MCPcopy Create free account
hub / github.com/comaps/comaps / GetPixelRect

Method GetPixelRect

libs/drape_frontend/text_shape.cpp:91–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89 }
90
91 m2::RectD GetPixelRect(ScreenBase const & screen, bool perspective) const override
92 {
93 if (perspective)
94 {
95 if (IsBillboard())
96 {
97 m2::PointD const pxPivot(screen.GtoP(m2::PointD(m_pivot)));
98 m2::PointD const pxPivotPerspective(screen.PtoP3d(pxPivot, -m_pivotZ));
99
100 m2::RectD pxRectPerspective = GetPixelRect(screen, false);
101 pxRectPerspective.Offset(-pxPivot);
102 pxRectPerspective.Offset(pxPivotPerspective);
103
104 return pxRectPerspective;
105 }
106 return GetPixelRectPerspective(screen);
107 }
108
109 m2::PointD pivot(screen.GtoP(m2::PointD(m_pivot)) + m2::PointD(m_offset));
110 double x = pivot.x;
111 double y = pivot.y;
112 if (m_anchor & dp::Left)
113 x += m_size.x;
114 else if (m_anchor & dp::Right)
115 x -= m_size.x;
116 else
117 {
118 float halfWidth = m_size.x / 2.0f;
119 x += halfWidth;
120 pivot.x -= halfWidth;
121 }
122
123 if (m_anchor & dp::Top)
124 y += m_size.y;
125 else if (m_anchor & dp::Bottom)
126 y -= m_size.y;
127 else
128 {
129 float halfHeight = m_size.y / 2.0f;
130 y += halfHeight;
131 pivot.y -= halfHeight;
132 }
133
134 return m2::RectD(std::min(x, pivot.x), std::min(y, pivot.y), std::max(x, pivot.x), std::max(y, pivot.y));
135 }
136
137 void GetPixelShape(ScreenBase const & screen, bool perspective, Rects & rects) const override
138 {

Callers

nothing calls this directly

Calls 3

PtoP3dMethod · 0.80
GtoPMethod · 0.45
OffsetMethod · 0.45

Tested by

no test coverage detected