/** * Check whether this intersection should be added to, or updated in, the warning manager * * @param airspace Airspace corresponding to current intersection */ void Intersection(const AbstractAirspace& airspace) { if (!airspace.IsActive()) return; // ignore inactive airspaces completely if (!warning_manager.GetConfig().IsClassEnabled(airspace.GetType()) || ExcludeAltitude(airspace)) return; AirspaceWarning *warning = warning_manager.GetWarningPtr(airspace); if (warning == NULL || warning->IsStateAccepted(warning_state)) { AirspaceInterceptSolution solution; if (mode_inside) { airspace.Intercept(state, perf, solution, state.location, state.location); } else { solution = Intercept(airspace, state, perf); } if (!solution.IsValid()) return; if (solution.elapsed_time > max_time) return; if (warning == NULL) warning = warning_manager.GetNewWarningPtr(airspace); warning->UpdateSolution(warning_state, solution); found = true; } }
void setup_outline(const AbstractAirspace &airspace) { if (settings.black_outline) canvas.SelectBlackPen(); else canvas.Select(airspace_look.pens[airspace.GetType()]); canvas.SelectHollowBrush(); }
bool AirspaceFilterData::Match(const GeoPoint &location, const FlatProjection &projection, const AbstractAirspace &as) const { if (cls != AirspaceClass::AIRSPACECLASSCOUNT && as.GetType() != cls) return false; if (name_prefix != nullptr && !as.MatchNamePrefix(name_prefix)) return false; if (!direction.IsNegative()) { const auto closest = as.ClosestPoint(location, projection); const auto bearing = location.Bearing(closest); auto direction_error = (bearing - direction).AsDelta().AbsoluteDegrees(); if (direction_error > fixed(18)) return false; } if (!negative(distance)) { const auto closest = as.ClosestPoint(location, projection); const auto distance = location.Distance(closest); if (distance > distance) return false; } return true; }
gcc_pure static bool CheckAirspace(const AbstractAirspace &airspace) { const AirspaceWarningConfig &config = CommonInterface::GetComputerSettings().airspace.warnings; return config.IsClassEnabled(airspace.GetType()) && !IsAcked(airspace); }
bool SetupInterior(const AbstractAirspace &airspace) { if (settings.fill_mode == AirspaceRendererSettings::FillMode::NONE) return false; const AirspaceClassLook &class_look = look.classes[airspace.GetType()]; canvas.Select(Brush(class_look.fill_color.WithAlpha(48))); canvas.SelectNullPen(); return true; }
bool SetupCanvas(const AbstractAirspace &airspace) { if (settings.black_outline) return true; AirspaceClass type = airspace.GetType(); if (settings.classes[type].border_width == 0) // Don't draw outlines if border_width == 0 return false; canvas.Select(look.classes[type].border_pen); return true; }
void setup_outline(const AbstractAirspace &airspace) { // set bit 1 in stencil buffer, where an outline is drawn glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glStencilFunc(GL_ALWAYS, 3, 3); glStencilMask(2); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); if (settings.black_outline) canvas.SelectBlackPen(); else canvas.Select(airspace_look.pens[airspace.GetType()]); canvas.SelectHollowBrush(); }
/** * Renders the AbstractAirspace on the canvas * @param as AbstractAirspace to render */ void Render(const AbstractAirspace& as) { int type = as.GetType(); if (type <= 0) return; // No intersections for this airspace if (m_intersections.empty()) return; // Select pens and brushes #ifndef USE_GDI Color color = airspace_look.colors[settings.colours[type]]; #ifdef ENABLE_OPENGL color = color.WithAlpha(48); #endif Brush brush(color); #else const Brush &brush = airspace_look.brushes[settings.brushes[type]]; canvas.SetTextColor(LightColor(airspace_look.colors[settings.colours[type]])); #endif PixelRect rcd; // Calculate top and bottom coordinate rcd.top = chart.screenY(as.GetTopAltitude(state)); if (as.IsBaseTerrain()) rcd.bottom = chart.screenY(fixed_zero); else rcd.bottom = chart.screenY(as.GetBaseAltitude(state)); // Iterate through the intersections for (auto it = m_intersections.begin(); it != m_intersections.end(); ++it) { const GeoPoint p_start = it->first; const GeoPoint p_end = it->second; const fixed distance_start = start.Distance(p_start); const fixed distance_end = start.Distance(p_end); // Determine left and right coordinate rcd.left = chart.screenX(distance_start); rcd.right = chart.screenX(distance_end); // only one edge found, next edge must be beyond screen if ((rcd.left == rcd.right) && (p_start == p_end)) { rcd.right = chart.screenX(chart.getXmax()); } // Draw the airspace RenderBox(rcd, brush, settings.black_outline, type); } }
void setup_interior(const AbstractAirspace &airspace, bool check_fillstencil = false) { // restrict drawing area and don't paint over previously drawn outlines if (check_fillstencil) glStencilFunc(GL_EQUAL, 1, 3); else glStencilFunc(GL_EQUAL, 0, 2); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); Color color = airspace_look.colors[settings.colours[airspace.GetType()]]; canvas.Select(Brush(color.WithAlpha(90))); canvas.SelectNullPen(); }
void SetupInterior(const AbstractAirspace &airspace, bool check_fillstencil = false) { const AirspaceClassLook &class_look = look.classes[airspace.GetType()]; // restrict drawing area and don't paint over previously drawn outlines if (check_fillstencil) glStencilFunc(GL_EQUAL, 1, 3); else glStencilFunc(GL_EQUAL, 0, 2); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); canvas.Select(Brush(class_look.fill_color.WithAlpha(90))); canvas.SelectNullPen(); }
bool SetupOutline(const AbstractAirspace &airspace) { AirspaceClass type = airspace.GetType(); if (settings.black_outline) canvas.SelectBlackPen(); else if (settings.classes[type].border_width == 0) // Don't draw outlines if border_width == 0 return false; else canvas.Select(look.classes[type].border_pen); canvas.SelectHollowBrush(); return true; }
void set_buffer_pens(const AbstractAirspace &airspace) { const unsigned color_index = settings.colours[airspace.GetType()]; #ifndef HAVE_HATCHED_BRUSH m_buffer.Select(airspace_look.solid_brushes[color_index]); #else /* HAVE_HATCHED_BRUSH */ #ifdef HAVE_ALPHA_BLEND if (settings.transparency && AlphaBlendAvailable()) { m_buffer.Select(airspace_look.solid_brushes[color_index]); } else { #endif // this color is used as the black bit m_buffer.SetTextColor(LightColor(airspace_look.colors[color_index])); // get brush, can be solid or a 1bpp bitmap m_buffer.Select(airspace_look.brushes[settings.brushes[airspace.GetType()]]); m_buffer.SetBackgroundOpaque(); m_buffer.SetBackgroundColor(COLOR_WHITE); #ifdef HAVE_ALPHA_BLEND } #endif m_buffer.SelectNullPen(); if (m_warnings.is_warning(airspace) || m_warnings.is_inside(airspace)) { m_stencil.SelectBlackBrush(); m_stencil.Select(airspace_look.medium_pen); } else { m_stencil.Select(airspace_look.thick_pen); m_stencil.SelectHollowBrush(); } #endif /* HAVE_HATCHED_BRUSH */ }
void AirspacePreviewRenderer::Draw(Canvas &canvas, const AbstractAirspace &airspace, const RasterPoint pt, unsigned radius, const AirspaceRendererSettings &settings, const AirspaceLook &look) { canvas.SelectHollowBrush(); if (settings.black_outline) canvas.SelectBlackPen(); else canvas.Select(look.pens[airspace.GetType()]); if (airspace.shape == AbstractAirspace::Shape::CIRCLE) canvas.circle(pt.x, pt.y, radius); else DrawPolygon(canvas, (const AirspacePolygon &)airspace, pt, radius); }
bool SetupOutline(const AbstractAirspace &airspace) { AirspaceClass type = airspace.GetType(); if (settings.black_outline) canvas.SelectBlackPen(); else if (settings.classes[type].border_width == 0) // Don't draw outlines if border_width == 0 return false; else canvas.Select(look.classes[type].border_pen); canvas.SelectHollowBrush(); // set bit 1 in stencil buffer, where an outline is drawn glStencilFunc(GL_ALWAYS, 3, 3); glStencilMask(2); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); return true; }
void SetBufferPens(const AbstractAirspace &airspace) { AirspaceClass airspace_class = airspace.GetType(); #ifndef HAVE_HATCHED_BRUSH buffer.Select(look.solid_brushes[airspace_class]); #else /* HAVE_HATCHED_BRUSH */ #ifdef HAVE_ALPHA_BLEND if (settings.transparency && AlphaBlendAvailable()) { buffer.Select(look.solid_brushes[airspace_class]); } else { #endif // this color is used as the black bit buffer.SetTextColor(LightColor(settings.classes[airspace_class].fill_color)); // get brush, can be solid or a 1bpp bitmap buffer.Select(look.brushes[settings.classes[airspace_class].brush]); buffer.SetBackgroundOpaque(); buffer.SetBackgroundColor(COLOR_WHITE); #ifdef HAVE_ALPHA_BLEND } #endif buffer.SelectNullPen(); if (use_stencil) { if (warnings.HasWarning(airspace) || warnings.IsInside(airspace) || settings.classes[airspace_class].fill_mode == AirspaceClassRendererSettings::FillMode::ALL) { stencil.SelectBlackBrush(); stencil.SelectNullPen(); } else { stencil.Select(look.thick_pen); stencil.SelectHollowBrush(); } } #endif /* HAVE_HATCHED_BRUSH */ }
void AirspacePreviewRenderer::Draw(Canvas &canvas, const AbstractAirspace &airspace, const RasterPoint pt, unsigned radius, const AirspaceRendererSettings &settings, const AirspaceLook &look) { AbstractAirspace::Shape shape = airspace.GetShape(); AirspaceClass type = airspace.GetType(); // Container for storing the points of a polygon airspace std::vector<RasterPoint> pts; if (shape == AbstractAirspace::Shape::POLYGON && !IsAncientHardware()) GetPolygonPoints(pts, (const AirspacePolygon &)airspace, pt, radius); if (PrepareFill(canvas, type, look, settings)) { DrawShape(canvas, shape, pt, radius, pts); UnprepareFill(canvas); } if (PrepareOutline(canvas, type, look, settings)) DrawShape(canvas, shape, pt, radius, pts); }
virtual void Visit(const AbstractAirspace &airspace) override { if (warnings.IsAcked(airspace)) return; AirspaceClass airspace_class = airspace.GetType(); if (settings.fill_mode == AirspaceRendererSettings::FillMode::NONE || settings.classes[airspace_class].fill_mode == AirspaceClassRendererSettings::FillMode::NONE) return; Begin(); SetBufferPens(airspace); switch (airspace.GetShape()) { case AbstractAirspace::Shape::CIRCLE: VisitCircle((const AirspaceCircle &)airspace); break; case AbstractAirspace::Shape::POLYGON: VisitPolygon((const AirspacePolygon &)airspace); break; } }
tstring AirspaceFormatter::GetNameAndClass(const AbstractAirspace &airspace) { return tstring(airspace.GetName()) + _T(" ") + GetClass(airspace.GetType()); }
bool IsAirspaceTypeVisible(const AbstractAirspace &airspace, const AirspaceRendererSettings &renderer_settings) { return renderer_settings.classes[airspace.GetType()].display; }
void SetupInterior(const AbstractAirspace &airspace) { Color color = settings.classes[airspace.GetType()].fill_color; canvas.Select(Brush(color.WithAlpha(48))); canvas.SelectNullPen(); }
bool AirspaceWarningManager::IsActive(const AbstractAirspace &airspace) const { return airspace.IsActive() && config.IsClassEnabled(airspace.GetType()) && !GetAckDay(airspace); }
inline void AirspaceIntersectionVisitorSlice::Render(const AbstractAirspace &as) const { AirspaceClass type = as.GetType(); // No intersections for this airspace if (intersections.empty()) return; PixelRect rcd; // Calculate top and bottom coordinate rcd.top = chart.ScreenY(as.GetTopAltitude(state)); if (as.IsBaseTerrain()) rcd.bottom = chart.ScreenY(fixed(0)); else rcd.bottom = chart.ScreenY(as.GetBaseAltitude(state)); int min_x = 1024, max_x = 0; // Iterate through the intersections for (const auto &i : intersections) { const GeoPoint &p_start = i.first; const GeoPoint &p_end = i.second; rcd.left = chart.ScreenX(start.Distance(p_start)); // only one edge found, next edge must be beyond screen if (p_start == p_end) rcd.right = chart.ScreenX(chart.GetXMax()); else rcd.right = chart.ScreenX(start.Distance(p_end)); if (rcd.left < min_x) min_x = rcd.left; if (rcd.right > max_x) max_x = rcd.right; // Draw the airspace RenderBox(rcd, type); } min_x += Layout::GetTextPadding(); max_x -= Layout::GetTextPadding(); /* draw the airspace name */ const TCHAR *name = as.GetName(); if (name != nullptr && !StringIsEmpty(name) && min_x < max_x) { canvas.SetBackgroundTransparent(); canvas.SetTextColor(COLOR_BLACK); const unsigned max_width = max_x - min_x; const PixelSize name_size = canvas.CalcTextSize(name); const int x = unsigned(name_size.cx) >= max_width ? min_x : (min_x + max_x - name_size.cx) / 2; const int y = (rcd.top + rcd.bottom - name_size.cy) / 2; canvas.DrawClippedText(x, y, max_x - x, name); } }
void setup_canvas(const AbstractAirspace &airspace) { if (!black) canvas.Select(airspace_look.pens[airspace.GetType()]); }
bool AirspaceVisiblePredicate::IsTypeVisible(const AbstractAirspace& airspace) const { return renderer_settings.display[airspace.GetType()]; }
void setup_interior(const AbstractAirspace &airspace) { Color color = airspace_look.colors[settings.colours[airspace.GetType()]]; canvas.Select(Brush(color.WithAlpha(48))); canvas.SelectNullPen(); }