本文整理汇总了C++中PixelRect::GetCenter方法的典型用法代码示例。如果您正苦于以下问题:C++ PixelRect::GetCenter方法的具体用法?C++ PixelRect::GetCenter怎么用?C++ PixelRect::GetCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PixelRect
的用法示例。
在下文中一共展示了PixelRect::GetCenter方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: renderer
void
InfoBoxContentWindArrow::OnCustomPaint(Canvas &canvas, const PixelRect &rc)
{
const auto &info = CommonInterface::Calculated();
const RasterPoint pt = rc.GetCenter();
UPixelScalar padding = Layout::FastScale(10);
UPixelScalar size = std::min(rc.right - rc.left, rc.bottom - rc.top);
if (size > padding)
size -= padding;
// Normalize the size because the Layout::Scale is applied
// by the DrawArrow() function again
size = size * 100 / Layout::Scale(100);
auto angle = info.wind.bearing - CommonInterface::Basic().attitude.heading;
PixelScalar length =
std::min(size, (UPixelScalar)std::max(10, iround(Quadruple(info.wind.norm))));
PixelScalar offset = -length / 2;
auto style = CommonInterface::GetMapSettings().wind_arrow_style;
WindArrowRenderer renderer(UIGlobals::GetLook().wind_arrow_info_box);
renderer.DrawArrow(canvas, pt, angle, length, style, offset);
}
示例2: assert
void
SymbolRenderer::DrawArrow(Canvas &canvas, PixelRect rc, Direction direction)
{
assert(direction == UP || direction == DOWN ||
direction == LEFT || direction == RIGHT);
PixelScalar size = std::min(rc.right - rc.left, rc.bottom - rc.top) / 5;
RasterPoint center = rc.GetCenter();
RasterPoint arrow[3];
if (direction == LEFT || direction == RIGHT) {
arrow[0].x = center.x + (direction == LEFT ? size : -size);
arrow[0].y = center.y + size;
arrow[1].x = center.x + (direction == LEFT ? -size : size);
arrow[1].y = center.y;
arrow[2].x = center.x + (direction == LEFT ? size : -size);
arrow[2].y = center.y - size;
} else if (direction == UP || direction == DOWN) {
arrow[0].x = center.x + size;
arrow[0].y = center.y + (direction == UP ? size : -size);
arrow[1].x = center.x;
arrow[1].y = center.y + (direction == UP ? -size : size);
arrow[2].x = center.x - size;
arrow[2].y = center.y + (direction == UP ? size : -size);
}
canvas.DrawTriangleFan(arrow, 3);
}
示例3: Clamp
void
HorizonRenderer::Draw(Canvas &canvas, const PixelRect &rc,
const HorizonLook &look,
const AttitudeState &attitude)
{
/*
This feature of having a backup artificial horizon based on inferred
orientation from GPS and vario data is useful, and reasonably well
tested, but has the issue of potentially invalidating use of XCSoar in
FAI contests due to rule ref Annex A to Section 3 (2010 Edition) 4.1.2
"No instruments permitting pilots to fly without visual reference to
the ground may be carried on board, even if made unserviceable." The
quality of XCSoar's pseudo-AH is arguably good enough that this
violates the rule. We need to seek clarification as to whether this
is the case or not.
*/
const RasterPoint center = rc.GetCenter();
const int radius = std::min(rc.right - rc.left, rc.bottom - rc.top) / 2
- Layout::Scale(1);
auto bank_degrees = attitude.IsBankAngleUseable()
? attitude.bank_angle.Degrees()
: 0.;
auto pitch_degrees = attitude.IsPitchAngleUseable()
? attitude.pitch_angle.Degrees()
: 0.;
auto phi = Clamp(bank_degrees, -89., 89.);
auto alpha = Angle::acos(Clamp(pitch_degrees / 50,
-1., 1.));
auto sphi = Angle::HalfCircle() - Angle::Degrees(phi);
auto alpha1 = sphi - alpha;
auto alpha2 = sphi + alpha;
// draw sky part
canvas.Select(look.sky_pen);
canvas.Select(look.sky_brush);
canvas.DrawSegment(center.x, center.y, radius, alpha2, alpha1, true);
// draw ground part
canvas.Select(look.terrain_pen);
canvas.Select(look.terrain_brush);
canvas.DrawSegment(center.x, center.y, radius, alpha1, alpha2, true);
// draw aircraft symbol
canvas.Select(look.aircraft_pen);
canvas.DrawLine(center.x + radius / 2, center.y, center.x - radius / 2, center.y);
canvas.DrawLine(center.x, center.y - radius / 4, center.x, center.y);
// draw 45 degree dash marks
const int rr2p = uround(radius * M_SQRT1_2) + Layout::Scale(1);
const int rr2n = rr2p - Layout::Scale(2);
canvas.DrawLine(center.x + rr2p, center.y - rr2p,
center.x + rr2n, center.y - rr2n);
canvas.DrawLine(center.x - rr2p, center.y - rr2p,
center.x - rr2n, center.y - rr2n);
}
示例4: renderer
void
InfoBoxContentWindArrow::OnCustomPaint(Canvas &canvas, const PixelRect &rc)
{
const auto &info = CommonInterface::Calculated();
const auto pt = rc.GetCenter();
const unsigned padding = Layout::FastScale(10u);
unsigned size = std::min(rc.GetWidth(), rc.GetHeight());
if (size > padding)
size -= padding;
// Normalize the size because the Layout::Scale is applied
// by the DrawArrow() function again
size = size * 100 / Layout::Scale(100);
auto angle = info.wind.bearing - CommonInterface::Basic().attitude.heading;
const int length =
std::min(size, std::max(10u, uround(4 * info.wind.norm)));
const int offset = -length / 2;
auto style = CommonInterface::GetMapSettings().wind_arrow_style;
WindArrowRenderer renderer(UIGlobals::GetLook().wind_arrow_info_box);
renderer.DrawArrow(canvas, pt, angle, length, style, offset);
}
示例5: assert
void
SymbolRenderer::DrawArrow(Canvas &canvas, PixelRect rc, Direction direction)
{
assert(direction == UP || direction == DOWN ||
direction == LEFT || direction == RIGHT);
auto size = std::min(rc.GetWidth(), rc.GetHeight()) / 5;
auto center = rc.GetCenter();
BulkPixelPoint arrow[3];
if (direction == LEFT || direction == RIGHT) {
arrow[0].x = center.x + (direction == LEFT ? size : -size);
arrow[0].y = center.y + size;
arrow[1].x = center.x + (direction == LEFT ? -size : size);
arrow[1].y = center.y;
arrow[2].x = center.x + (direction == LEFT ? size : -size);
arrow[2].y = center.y - size;
} else if (direction == UP || direction == DOWN) {
arrow[0].x = center.x + size;
arrow[0].y = center.y + (direction == UP ? size : -size);
arrow[1].x = center.x;
arrow[1].y = center.y + (direction == UP ? -size : size);
arrow[2].x = center.x - size;
arrow[2].y = center.y + (direction == UP ? size : -size);
}
canvas.DrawTriangleFan(arrow, 3);
}
示例6: PolygonRotateShift
void
NextArrowRenderer::DrawArrow(Canvas &canvas, const PixelRect &rc,
Angle angle)
{
/*
* Define arrow geometry for forward pointing arrow.
* These are the coordinates of the corners, relative to the center (o)
*
* + (0,-head_len)
* / \
* / \
* / \
* (-head_width,-head_base) +-+ +-+ (head_width,-head_base)
* (-tail_width,-head_base) | o | (tail_width,-head_base)
* | |
* | |
* (-tail_width,tail_len) +---+ (tail_width,tail_len)
*
* The "tail" of the arrow is slightly shorter than the "head" to avoid
* the corners of the tail to stick out of the bounding PixelRect.
*/
static constexpr auto head_len = 50;
static constexpr auto head_width = 36;
static constexpr auto head_base = head_len - head_width;
static constexpr auto tail_width = 16;
static constexpr auto tail_len = head_len - tail_width / 2;
// An array of the arrow corner coordinates.
RasterPoint arrow[] = {
{ 0, -head_len },
{ head_width, -head_base },
{ tail_width, -head_base },
{ tail_width, tail_len },
{ -tail_width, tail_len },
{ -tail_width, -head_base },
{ -head_width, -head_base },
};
/*
* Rotate the arrow, center it in the bounding rectangle, and scale
* it to fill the rectangle.
*
* Note that PolygonRotateShift scales a polygon with coordinates
* in the range -50 to +50 to fill a square with the size of the 'scale'
* argument.
*/
const auto size = std::min(rc.right - rc.left, rc.bottom - rc.top);
PolygonRotateShift(arrow, ARRAY_SIZE(arrow),
rc.GetCenter(), angle,
size, false);
// Draw the arrow.
canvas.Select(look.arrow_pen);
canvas.Select(look.arrow_brush);
canvas.DrawPolygon(arrow, ARRAY_SIZE(arrow));
}
示例7: OnPaint
virtual void OnPaint(Canvas &canvas) override {
canvas.ClearWhite();
const PixelRect rc = canvas.GetRect();
PixelPoint pt = rc.GetCenter();
canvas.SelectBlackPen();
canvas.SelectHollowBrush();
canvas.DrawCircle(pt.x, pt.y, 2);
renderer.Draw(canvas, Angle::Zero(), wind, pt, rc, WindArrowStyle::ARROW_HEAD);
}
示例8:
void
SymbolRenderer::DrawSign(Canvas &canvas, PixelRect rc, bool plus)
{
PixelScalar size = std::min(rc.right - rc.left, rc.bottom - rc.top) / 5;
RasterPoint center = rc.GetCenter();
// Draw horizontal bar
canvas.Rectangle(center.x - size, center.y - size / 3,
center.x + size, center.y + size / 3);
if (plus)
// Draw vertical bar
canvas.Rectangle(center.x - size / 3, center.y - size,
center.x + size / 3, center.y + size);
}
示例9:
void
SymbolRenderer::DrawSign(Canvas &canvas, PixelRect rc, bool plus)
{
unsigned size = std::min(rc.GetWidth(), rc.GetHeight()) / 5;
auto center = rc.GetCenter();
// Draw horizontal bar
canvas.Rectangle(center.x - size, center.y - size / 3,
center.x + size, center.y + size / 3);
if (plus)
// Draw vertical bar
canvas.Rectangle(center.x - size / 3, center.y - size,
center.x + size / 3, center.y + size);
}
示例10: scissor
void
DrawGlassBackground(Canvas &canvas, const PixelRect &rc, Color color)
{
canvas.DrawFilledRectangle(rc, color);
#if defined(EYE_CANDY) && defined(ENABLE_OPENGL)
if (color != COLOR_WHITE)
/* apply only to white background for now */
return;
const GLCanvasScissor scissor(rc);
const Color shadow = color.Shadow();
const RasterPoint center = rc.GetCenter();
const int size = std::min(rc.right - rc.left, rc.bottom - rc.top) / 4;
const RasterPoint vertices[] = {
{ center.x + 1024, center.y - 1024 },
{ center.x + 1024 + size, center.y - 1024 + size },
{ center.x - 1024, center.y + 1024 },
{ center.x - 1024 + size, center.y + 1024 + size },
};
glVertexPointer(2, GL_VALUE, 0, vertices);
const Color colors[] = {
shadow, color,
shadow, color,
};
glEnableClientState(GL_COLOR_ARRAY);
#ifdef HAVE_GLES
glColorPointer(4, GL_FIXED, 0, colors);
#else
glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors);
#endif
static_assert(ARRAY_SIZE(vertices) == ARRAY_SIZE(colors),
"Array size mismatch");
glDrawArrays(GL_TRIANGLE_STRIP, 0, ARRAY_SIZE(vertices));
glDisableClientState(GL_COLOR_ARRAY);
#endif
}
示例11: if
void
GlueMapWindow::UpdateProjection()
{
const PixelRect rc = GetClientRect();
/* not using MapWindowBlackboard here because these methods are
called by the main thread */
const NMEAInfo &basic = CommonInterface::Basic();
const DerivedInfo &calculated = CommonInterface::Calculated();
const MapSettings &settings_map = CommonInterface::GetMapSettings();
const bool circling =
CommonInterface::GetUIState().display_mode == DisplayMode::CIRCLING;
const RasterPoint center = rc.GetCenter();
if (circling || !IsNearSelf())
visible_projection.SetScreenOrigin(center.x, center.y);
else if (settings_map.cruise_orientation == DisplayOrientation::NORTH_UP ||
settings_map.cruise_orientation == DisplayOrientation::WIND_UP) {
RasterPoint offset{0, 0};
if (settings_map.glider_screen_position != 50 &&
settings_map.map_shift_bias != MapShiftBias::NONE) {
fixed x = fixed(0);
fixed y = fixed(0);
if (settings_map.map_shift_bias == MapShiftBias::TRACK) {
if (basic.track_available &&
basic.ground_speed_available &&
/* 8 m/s ~ 30 km/h */
basic.ground_speed > fixed(8)) {
auto angle = basic.track.Reciprocal() - visible_projection.GetScreenAngle();
const auto sc = angle.SinCos();
x = sc.first;
y = sc.second;
}
} else if (settings_map.map_shift_bias == MapShiftBias::TARGET) {
if (calculated.task_stats.current_leg.solution_remaining.IsDefined()) {
auto angle = calculated.task_stats.current_leg.solution_remaining
.vector.bearing.Reciprocal() - visible_projection.GetScreenAngle();
const auto sc = angle.SinCos();
x = sc.first;
y = sc.second;
}
}
fixed position_factor = fixed(50 - settings_map.glider_screen_position) / 100;
offset.x = PixelScalar(x * (rc.right - rc.left) * position_factor);
offset.y = PixelScalar(y * (rc.top - rc.bottom) * position_factor);
offset_history.Add(offset);
offset = offset_history.GetAverage();
}
visible_projection.SetScreenOrigin(center.x + offset.x, center.y + offset.y);
} else
visible_projection.SetScreenOrigin(center.x,
((rc.top - rc.bottom) * settings_map.glider_screen_position / 100) + rc.bottom);
if (!IsNearSelf()) {
/* no-op - the Projection's location is updated manually */
} else if (circling && calculated.thermal_locator.estimate_valid) {
const fixed d_t = calculated.thermal_locator.estimate_location.Distance(basic.location);
if (!positive(d_t)) {
SetLocationLazy(basic.location);
} else {
const fixed d_max = Double(visible_projection.GetMapScale());
const fixed t = std::min(d_t, d_max)/d_t;
SetLocation(basic.location.Interpolate(calculated.thermal_locator.estimate_location,
t));
}
} else if (basic.location_available)
// Pan is off
SetLocationLazy(basic.location);
else if (!visible_projection.IsValid() && terrain != nullptr)
/* if there's no GPS fix yet and no home waypoint, start at the
map center, to avoid showing a fully white map, which confuses
users */
SetLocation(terrain->GetTerrainCenter());
visible_projection.UpdateScreenBounds();
}