本文整理汇总了C++中WindowProjection类的典型用法代码示例。如果您正苦于以下问题:C++ WindowProjection类的具体用法?C++ WindowProjection怎么用?C++ WindowProjection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WindowProjection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ToGLM
glm::mat4
ToGLM(const WindowProjection &projection, const GeoPoint &reference)
{
fixed angle = projection.GetScreenAngle().Degrees();
fixed scale = projection.GetScale();
const RasterPoint &screen_origin = projection.GetScreenOrigin();
const GeoPoint &screen_location = projection.GetGeoLocation();
const GeoPoint projection_delta = reference - screen_location;
const fixed scale_r = scale * FAISphere::REARTH;
const fixed scale_x = scale_r * screen_location.latitude.fastcosine();
const fixed scale_y = -scale_r;
const glm::vec3 scale_vec(GLfloat(scale_x), GLfloat(scale_y), 1);
glm::mat4 matrix = glm::scale(glm::rotate(glm::translate(glm::mat4(),
glm::vec3(screen_origin.x,
screen_origin.y,
0)),
GLfloat(angle),
glm::vec3(0, 0, -1)),
scale_vec);
matrix = glm::translate(matrix,
glm::vec3(GLfloat(projection_delta.longitude.Native()),
GLfloat(projection_delta.latitude.Native()),
0.));
return matrix;
}
示例2: map
/**
* Draws the terrain to the given canvas
* @param canvas The drawing canvas
* @param map_projection The Projection
* @param sunazimuth Azimuth of the sun (for terrain shading)
*/
void
TerrainRenderer::Draw(Canvas &canvas,
const WindowProjection &map_projection,
const Angle sunazimuth)
{
const bool do_water = true;
const unsigned height_scale = 4;
const int interp_levels = 2;
const bool is_terrain = true;
const bool do_shading = is_terrain && SlopeShading;
const COLORRAMP *const color_ramp = &terrain_colors[TerrainRamp][0];
if (color_ramp != last_color_ramp) {
raster_renderer.ColorTable(color_ramp, do_water,
height_scale, interp_levels);
last_color_ramp = color_ramp;
}
{
RasterTerrain::Lease map(*terrain);
raster_renderer.ScanMap(map, map_projection);
}
raster_renderer.GenerateImage(is_terrain, do_shading, height_scale,
TerrainContrast, TerrainBrightness,
sunazimuth);
CopyTo(canvas, map_projection.GetScreenWidth(),
map_projection.GetScreenHeight());
}
示例3:
void
RasterRenderer::ScanMap(const RasterMap &map, const WindowProjection &projection)
{
// Coordinates of the MapWindow center
unsigned x = projection.GetScreenWidth() / 2;
unsigned y = projection.GetScreenHeight() / 2;
// GeoPoint corresponding to the MapWindow center
GeoPoint Gmid = projection.ScreenToGeo(x, y);
// GeoPoint "next to" Gmid (depends on terrain resolution)
GeoPoint Gneighbor = projection.ScreenToGeo(x + quantisation_pixels,
y + quantisation_pixels);
// Geographical edge length of pixel in the MapWindow center in meters
pixel_size = fixed_sqrt_half * Gmid.Distance(Gneighbor);
// set resolution
fixed map_pixel_size = map.pixel_distance(Gmid, 1);
fixed q = map_pixel_size / pixel_size;
if (pixel_size < fixed(3000)) {
/* round down to reduce slope shading artefacts (caused by
RasterBuffer interpolation) */
quantisation_effective = std::max(1, (int)q);
if (quantisation_effective > 25)
/* disable slope shading when zoomed in very near (not enough
terrain resolution to make a useful slope calculation) */
quantisation_effective = 0;
} else
/* disable slope shading when zoomed out very far (too tiny) */
quantisation_effective = 0;
height_matrix.Fill(map, projection, quantisation_pixels, true);
}
示例4: ApplyProjection
void
ApplyProjection(const WindowProjection &projection, const GeoPoint &reference)
{
fixed angle = projection.GetScreenAngle().Degrees();
fixed scale = projection.GetScale();
const RasterPoint &screen_origin = projection.GetScreenOrigin();
const GeoPoint &screen_location = projection.GetGeoLocation();
const GeoPoint projection_delta = reference - screen_location;
const fixed scale_r = scale * FAISphere::REARTH;
const fixed scale_x = scale_r * screen_location.latitude.fastcosine();
const fixed scale_y = -scale_r;
#ifdef HAVE_GLES
#ifdef FIXED_MATH
GLfixed fixed_angle = angle.as_glfixed();
#else
GLfixed fixed_angle = angle * (1<<16);
#endif
glTranslatex((int)screen_origin.x << 16, (int)screen_origin.y << 16, 0);
glRotatex(fixed_angle, 0, 0, -(1<<16));
#else
glTranslatef(screen_origin.x, screen_origin.y, 0.);
glRotatef((GLfloat)angle, 0., 0., -1.);
#endif
glScalef(GLfloat(scale_x), GLfloat(scale_y), 1.);
glTranslatef(GLfloat(projection_delta.longitude.Native()),
GLfloat(projection_delta.latitude.Native()),
0.);
}
示例5: helper
inline bool
AirspaceRenderer::DrawFill(Canvas &buffer_canvas, Canvas &stencil_canvas,
const WindowProjection &projection,
const AirspaceRendererSettings &settings,
const AirspaceWarningCopy &awc,
const AirspacePredicate &visible)
{
StencilMapCanvas helper(buffer_canvas, stencil_canvas, projection,
settings);
AirspaceVisitorMap v(helper, awc, settings,
look);
// JMW TODO wasteful to draw twice, can't it be drawn once?
// we are using two draws so borders go on top of everything
const auto range =
airspaces->QueryWithinRange(projection.GetGeoScreenCenter(),
projection.GetScreenDistanceMeters());
for (const auto &i : range) {
const AbstractAirspace &airspace = i.GetAirspace();
if (visible(airspace))
v.Visit(airspace);
}
return v.Commit();
}
示例6: assert
void
TransparentRendererCache::AlphaBlendTo(Canvas &canvas,
const WindowProjection &projection,
uint8_t alpha) const
{
assert(canvas.IsDefined());
assert(buffer.IsDefined());
assert(projection.IsValid());
assert(compare_projection.IsDefined());
assert(Check(projection));
if (empty)
return;
const unsigned width = projection.GetScreenWidth(),
height = projection.GetScreenHeight();
#ifdef USE_MEMORY_CANVAS
canvas.AlphaBlendNotWhite(0, 0, width, height,
buffer, 0, 0, width, height,
alpha);
#else
canvas.AlphaBlend(0, 0, width, height,
buffer, 0, 0, width, height,
alpha);
#endif
}
示例7: protect
void
TopographyThread::Trigger(const WindowProjection &_projection)
{
assert(_projection.IsValid());
const GeoBounds new_bounds = _projection.GetScreenBounds();
if (last_bounds.IsValid() && last_bounds.IsInside(new_bounds)) {
/* still inside cache bounds - now check if we crossed a scale
threshold for at least one file, which would mean we have to
update a file which was not updated for the current cache
bounds */
if (scale_threshold < 0 ||
_projection.GetMapScale() >= scale_threshold)
/* the cache is still fresh */
return;
}
last_bounds = new_bounds.Scale(1.1);
scale_threshold = store.GetNextScaleThreshold(_projection.GetMapScale());
{
const ScopeLock protect(mutex);
next_projection = _projection;
StandbyThread::Trigger();
}
}
示例8:
void
TopographyFileRenderer::UpdateVisibleShapes(const WindowProjection &projection)
{
if (file.GetSerial() == visible_serial &&
visible_bounds.IsInside(projection.GetScreenBounds()) &&
projection.GetScreenBounds().Scale(fixed_two).IsInside(visible_bounds))
/* cache is clean */
return;
visible_serial = file.GetSerial();
visible_bounds = projection.GetScreenBounds().Scale(fixed(1.2));
visible_shapes.clear();
visible_labels.clear();
for (auto it = file.begin(), end = file.end(); it != end; ++it) {
const XShape &shape = *it;
if (!visible_bounds.Overlaps(shape.get_bounds()))
continue;
if (shape.get_type() != MS_SHAPE_NULL)
visible_shapes.push_back(&shape);
if (shape.get_label() != NULL)
visible_labels.push_back(&shape);
}
}
示例9:
CompareProjection::CompareProjection(const WindowProjection &projection)
:corners(projection),
latitude_cos(corners.top_left.latitude.fastcosine()),
max_delta(SimpleSquareDistance(corners.top_left, corners.top_right,
latitude_cos) /
(projection.GetScreenWidth() * projection.GetScreenWidth()))
{
}
示例10: ConvertRect
bool
TopographyFile::Update(const WindowProjection &map_projection)
{
if (IsEmpty())
return false;
if (map_projection.GetMapScale() > scale_threshold)
/* not visible, don't update cache now */
return false;
const GeoBounds screenRect =
map_projection.GetScreenBounds();
if (cache_bounds.IsValid() && cache_bounds.IsInside(screenRect))
/* the cache is still fresh */
return false;
cache_bounds = map_projection.GetScreenBounds().Scale(fixed(2));
rectObj deg_bounds = ConvertRect(cache_bounds);
// Test which shapes are inside the given bounds and save the
// status to file.status
msShapefileWhichShapes(&file, dir, deg_bounds, 0);
// If not a single shape is inside the bounds
if (!file.status) {
// ... clear the whole buffer
ClearCache();
return false;
}
// Iterate through the shapefile entries
const ShapeList **current = &first;
auto it = shapes.begin();
for (int i = 0; i < file.numshapes; ++i, ++it) {
if (!msGetBit(file.status, i)) {
// If the shape is outside the bounds
// delete the shape from the cache
delete it->shape;
it->shape = NULL;
} else {
// is inside the bounds
if (it->shape == NULL)
// shape isn't cached yet -> cache the shape
it->shape = new XShape(&file, i, label_field);
// update list pointer
*current = it;
current = &it->next;
}
}
// end of list marker
*current = NULL;
++serial;
return true;
}
示例11: vp
void
MapOverlayBitmap::Draw(Canvas &canvas,
const WindowProjection &projection) noexcept
{
if (!simple_bounds.Overlaps(projection.GetScreenBounds()))
/* not visible, outside of screen area */
return;
auto clipped = Clip(bounds, projection.GetScreenBounds());
if (clipped.empty())
return;
GLTexture &texture = *bitmap.GetNative();
const PixelSize allocated = texture.GetAllocatedSize();
const double x_factor = double(texture.GetWidth()) / allocated.cx;
const double y_factor = double(texture.GetHeight()) / allocated.cy;
Point2D<GLfloat> coord[16];
BulkPixelPoint vertices[16];
const ScopeVertexPointer vp(vertices);
texture.Bind();
const ScopeTextureConstantAlpha blend(use_bitmap_alpha, alpha);
glEnableVertexAttribArray(OpenGL::Attribute::TEXCOORD);
glVertexAttribPointer(OpenGL::Attribute::TEXCOORD, 2, GL_FLOAT, GL_FALSE,
0, coord);
for (const auto &polygon : clipped) {
const auto &ring = polygon.outer();
size_t n = ring.size();
if (ring.front() == ring.back())
--n;
for (size_t i = 0; i < n; ++i) {
const auto v = GeoFrom2D(ring[i]);
auto p = MapInQuadrilateral(bounds, v);
coord[i].x = p.x * x_factor;
coord[i].y = p.y * y_factor;
if (bitmap.IsFlipped())
coord[i].y = 1 - coord[i].y;
vertices[i] = projection.GeoToScreen(v);
}
glDrawArrays(GL_TRIANGLE_FAN, 0, n);
}
glDisableVertexAttribArray(OpenGL::Attribute::TEXCOORD);
}
示例12: outline_renderer
inline void
AirspaceRenderer::DrawOutline(Canvas &canvas,
const WindowProjection &projection,
const AirspaceRendererSettings &settings,
const AirspacePredicate &visible) const
{
AirspaceOutlineRenderer outline_renderer(canvas, projection, look, settings);
airspaces->VisitWithinRange(projection.GetGeoScreenCenter(),
projection.GetScreenDistanceMeters(),
outline_renderer, visible);
}
示例13:
void
TransparentRendererCache::CopyAndTo(Canvas &canvas,
const WindowProjection &projection) const
{
if (empty)
return;
canvas.CopyAnd(0, 0,
projection.GetScreenWidth(), projection.GetScreenHeight(),
buffer, 0, 0);
}
示例14:
void
BackgroundDrawHelper::sun_from_wind(const WindowProjection& projection,
const SpeedVector& wind)
{
// draw sun from constant angle if very low wind speed
if (wind.norm < fixed_half) {
m_sun_azimuth = projection.GetScreenAngle() - Angle::degrees(fixed(45.0));
} else {
m_sun_azimuth = projection.GetScreenAngle() + wind.bearing;
}
}
示例15:
bool
TrailRenderer::LoadTrace(const TraceComputer &trace_computer,
unsigned min_time,
const WindowProjection &projection)
{
trace.clear();
trace_computer.LockedCopyTo(trace, min_time,
projection.GetGeoScreenCenter(),
projection.DistancePixelsToMeters(3));
return !trace.empty();
}