void DrawGeoBitmap(const RawBitmap &bitmap, PixelSize bitmap_size, const GeoBounds &bounds, const Projection &projection) { assert(bounds.IsValid()); const BulkPixelPoint vertices[] = { projection.GeoToScreen(bounds.GetNorthWest()), projection.GeoToScreen(bounds.GetNorthEast()), projection.GeoToScreen(bounds.GetSouthWest()), projection.GeoToScreen(bounds.GetSouthEast()), }; const ScopeVertexPointer vp(vertices); const GLTexture &texture = bitmap.BindAndGetTexture(); const PixelSize allocated = texture.GetAllocatedSize(); const GLfloat src_x = 0, src_y = 0, src_width = bitmap_size.cx, src_height = bitmap_size.cy; GLfloat x0 = src_x / allocated.cx; GLfloat y0 = src_y / allocated.cy; GLfloat x1 = (src_x + src_width) / allocated.cx; GLfloat y1 = (src_y + src_height) / allocated.cy; const GLfloat coord[] = { x0, y0, x1, y0, x0, y1, x1, y1, }; #ifdef USE_GLSL OpenGL::texture_shader->Use(); glEnableVertexAttribArray(OpenGL::Attribute::TEXCOORD); glVertexAttribPointer(OpenGL::Attribute::TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, coord); #else const GLEnable<GL_TEXTURE_2D> scope; OpenGL::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, 0, coord); #endif glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); #ifdef USE_GLSL glDisableVertexAttribArray(OpenGL::Attribute::TEXCOORD); OpenGL::solid_shader->Use(); #else glDisableClientState(GL_TEXTURE_COORD_ARRAY); #endif }
void MapCanvas::project(const Projection &projection, const SearchPointVector &points, RasterPoint *screen) { for (auto it = points.begin(); it != points.end(); ++it) *screen++ = projection.GeoToScreen(it->get_location()); }
void MapCanvas::Project(const Projection &projection, const SearchPointVector &points, BulkPixelPoint *screen) { for (auto it = points.begin(); it != points.end(); ++it) *screen++ = projection.GeoToScreen(it->GetLocation()); }
static void TestGeoScreenCouple(const Projection prj, const GeoPoint geo, long x, long y) { RasterPoint tmp_pt = prj.GeoToScreen(geo); ok1(tmp_pt.x == x); ok1(tmp_pt.y == y); GeoPoint tmp_geo = prj.ScreenToGeo(x, y); ok1(equals(tmp_geo.latitude, geo.latitude)); ok1(equals(tmp_geo.longitude, geo.longitude)); }
void TrailRenderer::DrawTraceVector(Canvas &canvas, const Projection &projection, const TracePointVector &trace) { points.GrowDiscard(trace.size()); unsigned n = 0; for (auto i = trace.begin(), end = trace.end(); i != end; ++i) points[n++] = projection.GeoToScreen(i->get_location()); canvas.DrawPolyline(points.begin(), n); }
void TrailRenderer::DrawTraceVector(Canvas &canvas, const Projection &projection, const TracePointVector &trace) { const unsigned n = trace.size(); RasterPoint *p = Prepare(n); for (const auto &i : trace) *p++ = projection.GeoToScreen(i.GetLocation()); DrawPreparedPolyline(canvas, n); }
void TrailRenderer::DrawTriangle(Canvas &canvas, const Projection &projection, const ContestTraceVector &trace) { assert(trace.size() == 5); const unsigned start = 1, n = 3; RasterPoint *p = Prepare(n); for (unsigned i = start; i < start + n; ++i) *p++ = projection.GeoToScreen(trace[i].GetLocation()); DrawPreparedPolygon(canvas, n); }
void OZWindow::OnPaint(Canvas &canvas) { canvas.ClearWhite(); if (oz == NULL) return; const int offset = 0; roz.Draw(canvas, OZRenderer::LAYER_SHADE, projection, *oz, offset); roz.Draw(canvas, OZRenderer::LAYER_INACTIVE, projection, *oz, offset); roz.Draw(canvas, OZRenderer::LAYER_ACTIVE, projection, *oz, offset); /* debugging for ObservationZone::GetBoundary() */ Pen pen(1, COLOR_RED); canvas.Select(pen); const OZBoundary boundary = oz->GetBoundary(); for (auto i = boundary.begin(), end = boundary.end(); i != end; ++i) { RasterPoint p = projection.GeoToScreen(*i); canvas.DrawLine(p.x - 3, p.y - 3, p.x + 3, p.y + 3); canvas.DrawLine(p.x + 3, p.y - 3, p.x - 3, p.y + 3); } }
void RenderObservationZone::Draw(Canvas &canvas, const Projection &projection, const ObservationZonePoint &_oz) const { switch (_oz.shape) { case ObservationZonePoint::LINE: case ObservationZonePoint::FAI_SECTOR: { const SectorZone &oz = (const SectorZone &)_oz; RasterPoint p_center = projection.GeoToScreen(oz.get_location()); if (layer != LAYER_ACTIVE) canvas.segment(p_center.x, p_center.y, projection.GeoToScreenDistance(oz.getRadius()), oz.getStartRadial() - projection.GetScreenAngle(), oz.getEndRadial() - projection.GetScreenAngle()); else { RasterPoint p_start = projection.GeoToScreen(oz.get_SectorStart()); RasterPoint p_end = projection.GeoToScreen(oz.get_SectorEnd()); canvas.two_lines(p_start, p_center, p_end); } break; } case ObservationZonePoint::CYLINDER: { const CylinderZone &oz = (const CylinderZone &)_oz; if (layer != LAYER_INACTIVE) { RasterPoint p_center = projection.GeoToScreen(oz.get_location()); canvas.circle(p_center.x, p_center.y, projection.GeoToScreenDistance(oz.getRadius())); } break; } case ObservationZonePoint::BGA_START: case ObservationZonePoint::SECTOR: { const SectorZone &oz = (const SectorZone &)_oz; if (layer != LAYER_INACTIVE) { RasterPoint p_center = projection.GeoToScreen(oz.get_location()); canvas.segment(p_center.x, p_center.y, projection.GeoToScreenDistance(oz.getRadius()), oz.getStartRadial() - projection.GetScreenAngle(), oz.getEndRadial() - projection.GetScreenAngle()); RasterPoint p_start = projection.GeoToScreen(oz.get_SectorStart()); RasterPoint p_end = projection.GeoToScreen(oz.get_SectorEnd()); canvas.two_lines(p_start, p_center, p_end); } break; } case ObservationZonePoint::KEYHOLE: case ObservationZonePoint::BGAFIXEDCOURSE: case ObservationZonePoint::BGAENHANCEDOPTION: { const SectorZone &oz = (const SectorZone &)_oz; RasterPoint p_center = projection.GeoToScreen(oz.get_location()); canvas.keyhole(p_center.x, p_center.y, projection.GeoToScreenDistance(fixed(500)), projection.GeoToScreenDistance(oz.getRadius()), oz.getStartRadial() - projection.GetScreenAngle(), oz.getEndRadial() - projection.GetScreenAngle()); break; } case ObservationZonePoint::ANNULAR_SECTOR: { const AnnularSectorZone &oz = (const AnnularSectorZone &)_oz; RasterPoint p_center = projection.GeoToScreen(oz.get_location()); canvas.annulus(p_center.x, p_center.y, projection.GeoToScreenDistance(oz.getInnerRadius()), projection.GeoToScreenDistance(oz.getRadius()), oz.getStartRadial() - projection.GetScreenAngle(), oz.getEndRadial() - projection.GetScreenAngle()); } } }
void OZRenderer::Draw(Canvas &canvas, Layer layer, const Projection &projection, const ObservationZonePoint &_oz, int offset) { if (layer == LAYER_SHADE && offset < 0) return; Prepare(canvas, layer, offset); switch (_oz.shape) { case ObservationZonePoint::LINE: case ObservationZonePoint::FAI_SECTOR: { const SectorZone &oz = (const SectorZone &)_oz; RasterPoint p_center = projection.GeoToScreen(oz.get_location()); if (layer != LAYER_ACTIVE) canvas.DrawSegment(p_center.x, p_center.y, projection.GeoToScreenDistance(oz.getRadius()), oz.getStartRadial() - projection.GetScreenAngle(), oz.getEndRadial() - projection.GetScreenAngle()); else { RasterPoint p_start = projection.GeoToScreen(oz.get_SectorStart()); RasterPoint p_end = projection.GeoToScreen(oz.get_SectorEnd()); canvas.DrawTwoLines(p_start, p_center, p_end); } break; } case ObservationZonePoint::CYLINDER: { const CylinderZone &oz = (const CylinderZone &)_oz; if (layer != LAYER_INACTIVE) { RasterPoint p_center = projection.GeoToScreen(oz.get_location()); canvas.circle(p_center.x, p_center.y, projection.GeoToScreenDistance(oz.getRadius())); } break; } case ObservationZonePoint::BGA_START: case ObservationZonePoint::SECTOR: { const SectorZone &oz = (const SectorZone &)_oz; if (layer != LAYER_INACTIVE) { RasterPoint p_center = projection.GeoToScreen(oz.get_location()); canvas.DrawSegment(p_center.x, p_center.y, projection.GeoToScreenDistance(oz.getRadius()), oz.getStartRadial() - projection.GetScreenAngle(), oz.getEndRadial() - projection.GetScreenAngle()); RasterPoint p_start = projection.GeoToScreen(oz.get_SectorStart()); RasterPoint p_end = projection.GeoToScreen(oz.get_SectorEnd()); canvas.DrawTwoLines(p_start, p_center, p_end); } break; } case ObservationZonePoint::KEYHOLE: case ObservationZonePoint::BGAFIXEDCOURSE: case ObservationZonePoint::BGAENHANCEDOPTION: { const SectorZone &oz = (const SectorZone &)_oz; RasterPoint p_center = projection.GeoToScreen(oz.get_location()); canvas.DrawKeyhole(p_center.x, p_center.y, projection.GeoToScreenDistance(fixed(500)), projection.GeoToScreenDistance(oz.getRadius()), oz.getStartRadial() - projection.GetScreenAngle(), oz.getEndRadial() - projection.GetScreenAngle()); break; } case ObservationZonePoint::ANNULAR_SECTOR: { const AnnularSectorZone &oz = (const AnnularSectorZone &)_oz; RasterPoint p_center = projection.GeoToScreen(oz.get_location()); canvas.DrawAnnulus(p_center.x, p_center.y, projection.GeoToScreenDistance(oz.getInnerRadius()), projection.GeoToScreenDistance(oz.getRadius()), oz.getStartRadial() - projection.GetScreenAngle(), oz.getEndRadial() - projection.GetScreenAngle()); } } Finish(canvas, layer); }