本文整理汇总了C++中WindowProjection::GetScreenBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ WindowProjection::GetScreenBounds方法的具体用法?C++ WindowProjection::GetScreenBounds怎么用?C++ WindowProjection::GetScreenBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WindowProjection
的用法示例。
在下文中一共展示了WindowProjection::GetScreenBounds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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);
}
}
示例2: 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;
}
示例3: 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);
}
示例4: LookupWeatherTerrainStyle
bool
RaspRenderer::Generate(const WindowProjection &projection,
const TerrainRendererSettings &settings)
{
const auto &style = LookupWeatherTerrainStyle(cache.GetMapName());
const bool do_water = style.do_water;
const unsigned height_scale = style.height_scale;
const int interp_levels = 5;
const ColorRamp *color_ramp = style.color_ramp;
const RasterMap *map = cache.GetMap();
if (map == nullptr)
return false;
if (!map->GetBounds().Overlaps(projection.GetScreenBounds()))
/* not visible */
return false;
if (color_ramp != last_color_ramp) {
raster_renderer.PrepareColorTable(color_ramp, do_water,
height_scale, interp_levels);
last_color_ramp = color_ramp;
}
raster_renderer.ScanMap(*map, projection);
raster_renderer.GenerateImage(false, height_scale,
settings.contrast, settings.brightness,
Angle::Zero(), false);
return true;
}
示例5: 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();
}
}
示例6: map
void
TerrainRenderer::Generate(const WindowProjection &map_projection,
const Angle sunazimuth)
{
#ifdef ENABLE_OPENGL
const GeoBounds &old_bounds = raster_renderer.GetBounds();
const GeoBounds &new_bounds = map_projection.GetScreenBounds();
assert(new_bounds.IsValid());
if (old_bounds.IsValid() && old_bounds.IsInside(new_bounds) &&
!IsLargeSizeDifference(old_bounds, new_bounds) &&
terrain_serial == terrain->GetSerial() &&
sunazimuth.CompareRoughly(last_sun_azimuth) &&
!raster_renderer.UpdateQuantisation())
/* no change since previous frame */
return;
#else
if (compare_projection.Compare(map_projection) &&
terrain_serial == terrain->GetSerial() &&
sunazimuth.CompareRoughly(last_sun_azimuth))
/* no change since previous frame */
return;
compare_projection = CompareProjection(map_projection);
#endif
terrain_serial = terrain->GetSerial();
last_sun_azimuth = 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 &&
settings.slope_shading != SlopeShading::OFF;
const bool do_contour = is_terrain &&
settings.contours != Contours::OFF;
const ColorRamp *const color_ramp = &terrain_colors[settings.ramp][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(do_shading, height_scale,
settings.contrast, settings.brightness,
sunazimuth,
do_contour);
}
示例7: AirspaceFillRenderer
AirspaceFillRenderer(Canvas &_canvas, const WindowProjection &_projection,
const AirspaceLook &_look,
const AirspaceWarningCopy &_warnings,
const AirspaceRendererSettings &_settings)
:MapCanvas(_canvas, _projection,
_projection.GetScreenBounds().Scale(fixed(1.1))),
look(_look), warning_manager(_warnings), settings(_settings)
{
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
示例8: AirspaceOutlineRenderer
AirspaceOutlineRenderer(Canvas &_canvas, const WindowProjection &_projection,
const AirspaceLook &_look,
const AirspaceRendererSettings &_settings)
:MapCanvas(_canvas, _projection,
_projection.GetScreenBounds().Scale(fixed(1.1))),
look(_look), settings(_settings)
{
if (settings.black_outline)
canvas.SelectBlackPen();
canvas.SelectHollowBrush();
}
示例9: AirspaceOutlineRenderer
AirspaceOutlineRenderer(Canvas &_canvas, const WindowProjection &_projection,
const AirspaceLook &_airspace_look,
bool _black)
:MapCanvas(_canvas, _projection,
_projection.GetScreenBounds().Scale(fixed(1.1))),
airspace_look(_airspace_look),
black(_black) {
if (black)
canvas.SelectBlackPen();
canvas.SelectHollowBrush();
}
示例10: buffer
StencilMapCanvas::StencilMapCanvas(Canvas &_buffer, Canvas &_stencil,
const WindowProjection &_proj,
const AirspaceRendererSettings &_settings)
:clip(_proj.GetScreenBounds().Scale(fixed(1.1))),
buffer(_buffer),
stencil(_stencil),
proj(_proj),
buffer_drawn(false),
use_stencil(false),
settings(_settings)
{
}
示例11: AirspaceVisitorRenderer
AirspaceVisitorRenderer(Canvas &_canvas, const WindowProjection &_projection,
const AirspaceLook &_look,
const AirspaceWarningCopy &_warnings,
const AirspaceRendererSettings &_settings)
:MapCanvas(_canvas, _projection,
_projection.GetScreenBounds().Scale(fixed(1.1))),
look(_look), warning_manager(_warnings), settings(_settings)
{
glStencilMask(0xff);
glClear(GL_STENCIL_BUFFER_BIT);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
示例12: settings
MapDrawHelper::MapDrawHelper(Canvas &_canvas, Canvas &_buffer, Canvas &_stencil,
const WindowProjection &_proj,
const AirspaceRendererSettings &_settings)
:clip(_proj.GetScreenBounds().Scale(fixed(1.1))),
m_canvas(_canvas),
m_buffer(_buffer),
m_stencil(_stencil),
m_proj(_proj),
m_buffer_drawn(false),
m_use_stencil(false),
settings(_settings)
{
}
示例13:
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 center = projection.ScreenToGeo(x, y);
// GeoPoint "next to" Gmid (depends on terrain resolution)
GeoPoint neighbor = projection.ScreenToGeo(x + quantisation_pixels,
y + quantisation_pixels);
// Geographical edge length of pixel in the MapWindow center in meters
pixel_size = M_SQRT1_2 * center.DistanceS(neighbor);
// set resolution
if (pixel_size < 3000) {
// Data point size of the (terrain) map in meters multiplied by 256
auto map_pixel_size = map.PixelDistance(center, 1);
// How many screen pixels does one data point stretch?
auto q = map_pixel_size / pixel_size;
/* round down to reduce slope shading artefacts (caused by
RasterBuffer interpolation) */
quantisation_effective = std::max(1, (int)q);
/* disable slope shading when zoomed in very near (not enough
terrain resolution to make a useful slope calculation) */
if (quantisation_effective > 25)
quantisation_effective = 0;
} else
/* disable slope shading when zoomed out very far (too tiny) */
quantisation_effective = 0;
#ifdef ENABLE_OPENGL
bounds = projection.GetScreenBounds().Scale(1.5);
bounds.IntersectWith(map.GetBounds());
height_matrix.Fill(map, bounds,
projection.GetScreenWidth() / quantisation_pixels,
projection.GetScreenHeight() / quantisation_pixels,
true);
last_quantisation_pixels = quantisation_pixels;
#else
height_matrix.Fill(map, projection, quantisation_pixels, true);
#endif
}
示例14:
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
if (pixel_size < fixed(3000)) {
/* round down to reduce slope shading artefacts (caused by
RasterBuffer interpolation) */
fixed map_pixel_size = map.PixelDistance(Gmid, 1);
fixed q = map_pixel_size / pixel_size;
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;
#ifdef ENABLE_OPENGL
bounds = projection.GetScreenBounds().Scale(fixed(1.5));
height_matrix.Fill(map, bounds,
projection.GetScreenWidth() / quantisation_pixels,
projection.GetScreenHeight() / quantisation_pixels,
true);
last_quantisation_pixels = quantisation_pixels;
#else
height_matrix.Fill(map, projection, quantisation_pixels, true);
#endif
}
示例15: ozv
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);
}