本文整理汇总了C++中m2::RectD类的典型用法代码示例。如果您正苦于以下问题:C++ RectD类的具体用法?C++ RectD怎么用?C++ RectD使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RectD类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
string ToString<m2::RectD>(m2::RectD const & rect)
{
ostringstream stream;
stream.precision(12);
stream << rect.minX() << " " << rect.minY() << " " << rect.maxX() << " " << rect.maxY();
return stream.str();
}
示例2: ToRotated
m2::AnyRectD ToRotated(m2::RectD const & rect, Navigator const & navigator)
{
double const dx = rect.SizeX();
double const dy = rect.SizeY();
return m2::AnyRectD(rect.Center(),
navigator.Screen().GetAngle(),
m2::RectD(-dx/2, -dy/2, dx/2, dy/2));
}
示例3: ClipSplineByRect
vector<m2::SharedSpline> ClipSplineByRect(m2::RectD const & rect, m2::SharedSpline const & spline)
{
vector<m2::SharedSpline> result;
vector<m2::PointD> const & path = spline->GetPath();
if (path.size() < 2)
return result;
m2::RectD splineRect;
for (m2::PointD const & p : path)
splineRect.Add(p);
// Check for spline is inside.
if (rect.IsRectInside(splineRect))
{
result.push_back(spline);
return result;
}
// Check for spline is outside.
if (!rect.IsIntersect(splineRect))
return result;
// Divide spline into parts.
result.reserve(2);
m2::PointD p1, p2;
int code1 = 0;
int code2 = 0;
m2::SharedSpline s;
s.Reset(new m2::Spline(path.size()));
for (size_t i = 0; i < path.size() - 1; i++)
{
p1 = path[i];
p2 = path[i + 1];
if (m2::Intersect(rect, p1, p2, code1, code2))
{
if ((p1 - p2).IsAlmostZero())
continue;
if (s.IsNull())
s.Reset(new m2::Spline(path.size() - i));
s->AddPoint(p1);
if (code2 != 0 || i + 2 == path.size())
{
s->AddPoint(p2);
result.push_back(s);
s.Reset(nullptr);
}
}
}
return result;
}
示例4: SetFromRects
void ScreenBase::SetFromRects(m2::AnyRectD const & glbRect, m2::RectD const & pxRect)
{
double hScale = glbRect.GetLocalRect().SizeX() / pxRect.SizeX();
double vScale = glbRect.GetLocalRect().SizeY() / pxRect.SizeY();
m_Scale = max(hScale, vScale);
m_Angle = glbRect.Angle();
m_Org = glbRect.GlobalCenter();
UpdateDependentParameters();
}
示例5: CalcLimitRect
void Framework::ShowNode(TCountryId const & idx, bool zoomToDownloadButton)
{
if (zoomToDownloadButton)
{
m2::RectD const rect = CalcLimitRect(idx, m_work.GetStorage(), m_work.GetCountryInfoGetter());
m_work.SetViewportCenter(rect.Center(), 10);
}
else
{
m_work.ShowNode(idx);
}
}
示例6: Init
void Init()
{
m_depthLayer = m_f.GetLayer();
if (m_depthLayer == feature::LAYER_TRANSPARENT_TUNNEL)
m_depthLayer = feature::LAYER_EMPTY;
if (m_geomType == feature::GEOM_POINT)
m_priorityModifier = (double)m_f.GetPopulation() / 7E9;
else
{
m2::RectD const r = m_f.GetLimitRect(m_zoomLevel);
m_priorityModifier = min(1.0, r.SizeX() * r.SizeY() * 10000.0);
}
}
示例7: SetRankPivot
void Engine::SetRankPivot(SearchParams const & params, m2::RectD const & viewport,
bool viewportSearch, Query & processor)
{
if (!viewportSearch && params.IsValidPosition())
{
m2::PointD const pos = MercatorBounds::FromLatLon(params.m_lat, params.m_lon);
if (m2::Inflate(viewport, viewport.SizeX() / 4.0, viewport.SizeY() / 4.0).IsPointInside(pos))
{
processor.SetRankPivot(pos);
return;
}
}
processor.SetRankPivot(viewport.Center());
}
示例8: IsIntersectedByRegionImpl
vector<TCountryId> CountryInfoGetter::GetRegionsCountryIdByRect(m2::RectD const & rect) const
{
size_t constexpr kAverageSize = 10;
vector<TCountryId> result;
result.reserve(kAverageSize);
for (size_t id = 0; id < m_countries.size(); ++id)
{
if (rect.IsRectInside(m_countries[id].m_rect) ||
(rect.IsIntersect(m_countries[id].m_rect) && IsIntersectedByRegionImpl(id, rect)))
{
result.push_back(m_countries[id].m_countryId);
}
}
return result;
}
示例9: CalculateCenter
m2::PointD CalculateCenter(double scale, m2::RectD const & pixelRect,
m2::PointD const & userPos, m2::PointD const & pixelPos,
double azimuth)
{
m2::PointD formingVector = (pixelRect.Center() - pixelPos) * scale;
formingVector.y = -formingVector.y;
formingVector.Rotate(azimuth);
return userPos + formingVector;
}
示例10: GetPrettyFollowAnimation
drape_ptr<SequenceAnimation> GetPrettyFollowAnimation(ScreenBase const & startScreen, m2::PointD const & userPos, double targetScale,
double targetAngle, m2::PointD const & endPixelPos)
{
auto sequenceAnim = make_unique_dp<SequenceAnimation>();
sequenceAnim->SetCustomType(kPrettyFollowAnim);
m2::RectD const viewportRect = startScreen.PixelRectIn3d();
ScreenBase tmp = startScreen;
tmp.SetAngle(targetAngle);
tmp.MatchGandP3d(userPos, viewportRect.Center());
double const moveDuration = PositionInterpolator::GetMoveDuration(startScreen.GetOrg(), tmp.GetOrg(), startScreen);
ASSERT_GREATER(moveDuration, 0.0, ());
double const scaleFactor = moveDuration / kMaxAnimationTimeSec * 2.0;
tmp = startScreen;
if (moveDuration > 0.0)
{
tmp.SetScale(startScreen.GetScale() * scaleFactor);
auto zoomOutAnim = make_unique_dp<MapLinearAnimation>();
zoomOutAnim->SetScale(startScreen.GetScale(), tmp.GetScale());
zoomOutAnim->SetMaxDuration(kMaxAnimationTimeSec * 0.5);
sequenceAnim->AddAnimation(move(zoomOutAnim));
tmp.MatchGandP3d(userPos, viewportRect.Center());
auto moveAnim = make_unique_dp<MapLinearAnimation>();
moveAnim->SetMove(startScreen.GetOrg(), tmp.GetOrg(), viewportRect, tmp.GetScale());
moveAnim->SetMaxDuration(kMaxAnimationTimeSec);
sequenceAnim->AddAnimation(move(moveAnim));
}
auto followAnim = make_unique_dp<MapFollowAnimation>(tmp, userPos, endPixelPos,
tmp.GetScale(), targetScale,
tmp.GetAngle(), targetAngle,
false /* isAutoZoom */);
followAnim->SetMaxDuration(kMaxAnimationTimeSec * 0.5);
sequenceAnim->AddAnimation(move(followAnim));
return sequenceAnim;
}
示例11: ScaleInto
ScreenBase const ScaleInto(ScreenBase const & screen, m2::RectD boundRect)
{
ReduceRectHack(boundRect);
ScreenBase res = screen;
double scale = 1;
m2::RectD clipRect = res.ClipRect();
ASSERT(boundRect.IsPointInside(clipRect.Center()), ("center point should be inside boundRect"));
if (clipRect.minX() < boundRect.minX())
{
double k = (boundRect.minX() - clipRect.Center().x) / (clipRect.minX() - clipRect.Center().x);
scale /= k;
clipRect.Scale(k);
}
if (clipRect.maxX() > boundRect.maxX())
{
double k = (boundRect.maxX() - clipRect.Center().x) / (clipRect.maxX() - clipRect.Center().x);
scale /= k;
clipRect.Scale(k);
}
if (clipRect.minY() < boundRect.minY())
{
double k = (boundRect.minY() - clipRect.Center().y) / (clipRect.minY() - clipRect.Center().y);
scale /= k;
clipRect.Scale(k);
}
if (clipRect.maxY() > boundRect.maxY())
{
double k = (boundRect.maxY() - clipRect.Center().y) / (clipRect.maxY() - clipRect.Center().y);
scale /= k;
clipRect.Scale(k);
}
res.Scale(scale);
res.SetOrg(clipRect.Center());
return res;
}
示例12: OnResize
void FrontendRenderer::OnResize(ScreenBase const & screen)
{
m2::RectD const viewportRect = screen.isPerspective() ? screen.PixelRectIn3d() : screen.PixelRect();
m_myPositionController->UpdatePixelPosition(screen);
m_myPositionController->OnNewPixelRect();
m_viewport.SetViewport(0, 0, viewportRect.SizeX(), viewportRect.SizeY());
m_contextFactory->getDrawContext()->resize(viewportRect.SizeX(), viewportRect.SizeY());
RefreshProjection(screen);
RefreshPivotTransform(screen);
m_framebuffer->SetSize(viewportRect.SizeX(), viewportRect.SizeY());
}
示例13: ForEachFeatureInMwmRectAndScale
void Editor::ForEachFeatureInMwmRectAndScale(MwmSet::MwmId const & id,
TFeatureTypeFunctor const & f,
m2::RectD const & rect,
uint32_t /*scale*/)
{
auto mwmFound = m_features.find(id);
if (mwmFound == m_features.end())
return;
// TODO(AlexZ): Check that features are visible at this scale.
// Process only new (created) features.
for (auto & index : mwmFound->second)
{
FeatureTypeInfo & ftInfo = index.second;
if (ftInfo.m_status == FeatureStatus::Created &&
rect.IsPointInside(ftInfo.m_feature.GetCenter()))
f(ftInfo.m_feature);
}
}
示例14: ShrinkInto
ScreenBase const ShrinkInto(ScreenBase const & screen, m2::RectD boundRect)
{
ReduceRectHack(boundRect);
ScreenBase res = screen;
m2::RectD clipRect = res.ClipRect();
if (clipRect.minX() < boundRect.minX())
clipRect.Offset(boundRect.minX() - clipRect.minX(), 0);
if (clipRect.maxX() > boundRect.maxX())
clipRect.Offset(boundRect.maxX() - clipRect.maxX(), 0);
if (clipRect.minY() < boundRect.minY())
clipRect.Offset(0, boundRect.minY() - clipRect.minY());
if (clipRect.maxY() > boundRect.maxY())
clipRect.Offset(0, boundRect.maxY() - clipRect.maxY());
res.SetOrg(clipRect.Center());
// This assert fails near x = 180 (Philipines).
//ASSERT ( boundRect.IsRectInside(res.ClipRect()), (clipRect, res.ClipRect()) );
return res;
}
示例15: drawRectangle
void ShapeRenderer::drawRectangle(m2::RectD const & r, graphics::Color const & c, double depth)
{
uint32_t id = base_t::mapInfo(Brush::Info(c));
Resource const * res = base_t::fromID(id);
if (res == 0)
{
LOG(LDEBUG, ("cannot map color"));
return;
}
m2::PointF rectPts[4] = {
m2::PointF(r.minX(), r.minY()),
m2::PointF(r.maxX(), r.minY()),
m2::PointF(r.minX(), r.maxY()),
m2::PointF(r.maxX(), r.maxY())
};
GeometryPipeline & p = pipeline(res->m_pipelineID);
shared_ptr<gl::BaseTexture> texture = p.texture();
if (!texture)
{
LOG(LDEBUG, ("returning as no texture is reserved"));
return;
}
m2::PointF texPt = texture->mapPixel(m2::RectF(res->m_texRect).Center());
m2::PointF normal(0, 0);
addTexturedStripStrided(
rectPts,
sizeof(m2::PointF),
&normal,
0,
&texPt,
0,
4,
depth,
res->m_pipelineID
);
}