Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'geometry/screenbase.hpp')
-rw-r--r--geometry/screenbase.hpp106
1 files changed, 36 insertions, 70 deletions
diff --git a/geometry/screenbase.hpp b/geometry/screenbase.hpp
index 1aee190597..a50ce0deb7 100644
--- a/geometry/screenbase.hpp
+++ b/geometry/screenbase.hpp
@@ -2,6 +2,7 @@
#include "point2d.hpp"
#include "rect2d.hpp"
+#include "aa_rect2d.hpp"
#include "../base/math.hpp"
@@ -18,9 +19,10 @@ enum EOrientation
class ScreenBase
{
m2::RectD m_PixelRect;
- m2::RectD m_GlobalRect;
+
double m_Scale;
- double m_Angle;
+ ang::AngleD m_Angle;
+ m2::PointD m_Org;
protected:
@@ -32,9 +34,12 @@ protected:
/// @{
math::Matrix<double, 3, 3> m_GtoP;
- /// Pixel to Global conversion matrix. GtoP inverted
+ /// Pixel to Global conversion matrix. Inverted GtoP matrix.
math::Matrix<double, 3, 3> m_PtoG;
+ /// Global Rect
+ m2::AARectD m_GlobalRect;
+
/// X-axis aligned global rect used for clipping
m2::RectD m_ClipRect;
@@ -47,57 +52,35 @@ protected:
public:
ScreenBase();
- ScreenBase(m2::RectI const & pxRect, m2::RectD const & glbRect);
+ ScreenBase(m2::RectI const & pxRect, m2::AARectD const & glbRect);
- void SetFromRect(m2::RectD const & rect);
+ void SetFromRect(m2::AARectD const & rect);
void SetOrg(m2::PointD const & p);
void Move(double dx, double dy);
- void MoveG(m2::PointD const & delta);
+ void MoveG(m2::PointD const & p);
+
void Scale(double scale);
void Rotate(double angle);
- void ReverseTransformInPixelCoords(double s, double a, double dx, double dy);
-
- void OnSize(m2::RectI const & r)
- {
- m_PixelRect = m2::RectD(r);
- UpdateDependentParameters();
- }
- void OnSize(int x0, int y0, int w, int h)
- {
- m_PixelRect = m2::RectD(x0, y0, x0 + w, y0 + h);
- UpdateDependentParameters();
- }
+ void OnSize(m2::RectI const & r);
+ void OnSize(int x0, int y0, int w, int h);
public:
- inline double GetScale() const { return m_Scale; };
-
- inline double GetAngle() const
- {
- return m_Angle;
- }
-
- inline int GetWidth() const
- {
- return my::rounds(m_PixelRect.SizeX());
- }
-
- inline int GetHeight() const
- {
- return my::rounds(m_PixelRect.SizeY());
- }
+ double GetScale() const;
+ double GetAngle() const;
+ int GetWidth() const;
+ int GetHeight() const;
- /// @warning ClipRect() returns a PtoG(m_PixelRect) rect.
- inline m2::RectD const & ClipRect() const
+ inline m2::PointD GtoP(m2::PointD const & pt) const
{
- return m_ClipRect;
+ return pt * m_GtoP;
}
- inline m2::PointD GtoP(m2::PointD const & pt) const
+ inline m2::PointD PtoG(m2::PointD const & pt) const
{
- return pt * m_GtoP;
+ return pt * m_PtoG;
}
inline void GtoP(double & x, double & y) const
@@ -107,51 +90,33 @@ public:
y = tempX * m_GtoP(1, 0) + y * m_GtoP(1, 1) + m_GtoP(2, 1);
}
- void GtoP(m2::RectD const & gr, m2::RectD & sr) const;
- void PtoG(m2::RectD const & sr, m2::RectD & gr) const;
-
- math::Matrix<double, 3, 3> const GtoPMatrix() const
+ inline void PtoG(double & x, double & y) const
{
- return m_GtoP;
+ double tempX = x;
+ x = tempX * m_PtoG(0, 0) + y * m_PtoG(1, 0) + m_PtoG(2, 0);
+ y = tempX * m_PtoG(0, 1) + y * m_PtoG(1, 1) + m_PtoG(2, 1);
}
- math::Matrix<double, 3, 3> const PtoGMatrix() const
- {
- return m_PtoG;
- }
+ void GtoP(m2::RectD const & gr, m2::RectD & sr) const;
+ void PtoG(m2::RectD const & pr, m2::RectD & gr) const;
- m2::RectD const & PixelRect() const
- {
- return m_PixelRect;
- }
+ math::Matrix<double, 3, 3> const & GtoPMatrix() const;
+ math::Matrix<double, 3, 3> const & PtoGMatrix() const;
- m2::RectD const & GlobalRect() const
- {
- return m_GlobalRect;
- }
+ m2::RectD const & PixelRect() const;
+ m2::AARectD const & GlobalRect() const;
+ m2::RectD const & ClipRect() const;
/// Compute arbitrary pixel transformation, that translates the (oldPt1, oldPt2) -> (newPt1, newPt2)
static math::Matrix<double, 3, 3> const CalcTransform(m2::PointD const & oldPt1, m2::PointD const & oldPt2,
m2::PointD const & newPt1, m2::PointD const & newPt2);
- /// Setting GtoP matrix extracts the Angle and GlobalRect, leaving PixelRect intact
+ /// Setting GtoP matrix extracts the Angle and m_Org parameters, leaving PixelRect intact
void SetGtoPMatrix(math::Matrix<double, 3, 3> const & m);
/// Extracting parameters from matrix, that is supposed to represent GtoP transformation
static void ExtractGtoPParams(math::Matrix<double, 3, 3> const & m, double & a, double & s, double & dx, double & dy);
- inline m2::PointD PtoG(m2::PointD const & pt) const
- {
- return pt * m_PtoG;
- }
-
- inline void PtoG(double & x, double & y) const
- {
- double tempX = x;
- x = tempX * m_PtoG(0, 0) + y * m_PtoG(1, 0) + m_PtoG(2, 0);
- y = tempX * m_PtoG(0, 1) + y * m_PtoG(1, 1) + m_PtoG(2, 1);
- }
-
bool operator != (ScreenBase const & src) const
{
return !(*this == src);
@@ -163,6 +128,7 @@ public:
}
};
-bool IsPanning(ScreenBase const & s1, ScreenBase const & s2);
+/// checking whether the s1 transforms into s2 without scaling, only with shift and rotation
+bool IsPanningAndRotate(ScreenBase const & s1, ScreenBase const & s2);
#include "../base/stop_mem_debug.hpp"