forked from organicmaps/organicmaps
From this moment we will set and reset state for overlay element instead of cloning element with new transformation
This commit is contained in:
parent
e56e360285
commit
c69c3788e0
12 changed files with 58 additions and 66 deletions
|
@ -13,13 +13,6 @@ namespace graphics
|
|||
m_ci(p.m_ci)
|
||||
{}
|
||||
|
||||
CircleElement::CircleElement(CircleElement const & ce, math::Matrix<double, 3, 3> const & m)
|
||||
: base_t(ce),
|
||||
m_ci(ce.m_ci)
|
||||
{
|
||||
setPivot(ce.pivot() * m);
|
||||
}
|
||||
|
||||
vector<m2::AnyRectD> const & CircleElement::boundRects() const
|
||||
{
|
||||
if (isDirtyRect())
|
||||
|
@ -72,8 +65,9 @@ namespace graphics
|
|||
res->m_pipelineID);
|
||||
}
|
||||
|
||||
OverlayElement * CircleElement::clone(math::Matrix<double, 3, 3> const & m) const
|
||||
void CircleElement::setTransformation(const math::Matrix<double, 3, 3> & m)
|
||||
{
|
||||
return new CircleElement(*this, m);
|
||||
setPivot(pivot() * getResetMatrix() * m);
|
||||
base_t::setTransformation(m);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,12 +26,11 @@ namespace graphics
|
|||
};
|
||||
|
||||
CircleElement(Params const & p);
|
||||
CircleElement(CircleElement const & ce, math::Matrix<double, 3, 3> const & m);
|
||||
|
||||
vector<m2::AnyRectD> const & boundRects() const;
|
||||
|
||||
void draw(OverlayRenderer * s, math::Matrix<double, 3, 3> const & m) const;
|
||||
|
||||
OverlayElement * clone(math::Matrix<double, 3, 3> const & m) const;
|
||||
void setTransformation(const math::Matrix<double, 3, 3> & m);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -24,7 +24,8 @@ namespace graphics
|
|||
m_isDirtyRect(true),
|
||||
m_isDirtyLayout(true),
|
||||
m_isDirtyRoughRect(true),
|
||||
m_userInfo(p.m_userInfo)
|
||||
m_userInfo(p.m_userInfo),
|
||||
m_inverseMatrix(math::Identity<double, 3>())
|
||||
{}
|
||||
|
||||
m2::PointD const OverlayElement::computeTopLeft(m2::PointD const & sz,
|
||||
|
@ -229,4 +230,18 @@ namespace graphics
|
|||
return m_depth;
|
||||
}
|
||||
|
||||
math::Matrix<double, 3, 3> const & OverlayElement::getResetMatrix() const
|
||||
{
|
||||
return m_inverseMatrix;
|
||||
}
|
||||
|
||||
void OverlayElement::setTransformation(const math::Matrix<double, 3, 3> & m)
|
||||
{
|
||||
m_inverseMatrix = math::Inverse(m);
|
||||
}
|
||||
|
||||
void OverlayElement::resetTransformation()
|
||||
{
|
||||
setTransformation(math::Identity<double, 3>());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,11 @@ namespace graphics
|
|||
mutable bool m_isDirtyRoughRect;
|
||||
mutable m2::RectD m_roughBoundRect;
|
||||
|
||||
math::Matrix<double, 3, 3> m_inverseMatrix;
|
||||
|
||||
protected:
|
||||
math::Matrix<double, 3, 3> const & getResetMatrix() const;
|
||||
|
||||
public:
|
||||
|
||||
UserInfo m_userInfo;
|
||||
|
@ -62,11 +67,16 @@ namespace graphics
|
|||
OverlayElement(Params const & p);
|
||||
virtual ~OverlayElement();
|
||||
|
||||
virtual OverlayElement * clone(math::Matrix<double, 3, 3> const & m) const = 0;
|
||||
|
||||
/// PLEASE, REMEMBER THE REFERENCE!!!
|
||||
virtual vector<m2::AnyRectD> const & boundRects() const = 0;
|
||||
virtual void draw(OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const = 0;
|
||||
/// Set new transformation ! RELATIVE TO INIT STATE ! for drawing and safe information for reseting
|
||||
/// Need to call base class method
|
||||
virtual void setTransformation(math::Matrix<double, 3, 3> const & m) = 0;
|
||||
/// This method reset transformation to initial state.
|
||||
/// Geometry stored in coordinates relative to the tile.
|
||||
/// Need to call base class method
|
||||
virtual void resetTransformation();
|
||||
|
||||
virtual double priority() const;
|
||||
|
||||
|
|
|
@ -27,14 +27,6 @@ namespace graphics
|
|||
setIsValid((m_glyphLayout.firstVisible() == 0) && (m_glyphLayout.lastVisible() == visText().size()));
|
||||
}
|
||||
|
||||
PathTextElement::PathTextElement(PathTextElement const & src, math::Matrix<double, 3, 3> const & m)
|
||||
: TextElement(src),
|
||||
m_glyphLayout(src.m_glyphLayout, m)
|
||||
{
|
||||
setPivot(m_glyphLayout.pivot());
|
||||
setIsValid((m_glyphLayout.firstVisible() == 0) && (m_glyphLayout.lastVisible() == visText().size()));
|
||||
}
|
||||
|
||||
vector<m2::AnyRectD> const & PathTextElement::boundRects() const
|
||||
{
|
||||
if (isDirtyRect())
|
||||
|
@ -92,8 +84,11 @@ namespace graphics
|
|||
m_glyphLayout.setPivot(pivot);
|
||||
}
|
||||
|
||||
OverlayElement * PathTextElement::clone(math::Matrix<double, 3, 3> const & m) const
|
||||
void PathTextElement::setTransformation(const math::Matrix<double, 3, 3> & m)
|
||||
{
|
||||
return new PathTextElement(*this, m);
|
||||
m_glyphLayout = GlyphLayout(m_glyphLayout, getResetMatrix() * m);
|
||||
TextElement::setPivot(m_glyphLayout.pivot());
|
||||
setIsValid((m_glyphLayout.firstVisible() == 0) && (m_glyphLayout.lastVisible() == visText().size()));
|
||||
TextElement::setTransformation(m);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,14 +23,12 @@ namespace graphics
|
|||
};
|
||||
|
||||
PathTextElement(Params const & p);
|
||||
PathTextElement(PathTextElement const & src, math::Matrix<double, 3, 3> const & m);
|
||||
|
||||
vector<m2::AnyRectD> const & boundRects() const;
|
||||
|
||||
void draw(OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const;
|
||||
|
||||
void setPivot(m2::PointD const & pivot);
|
||||
|
||||
OverlayElement * clone(math::Matrix<double, 3, 3> const & m) const;
|
||||
void setTransformation(const math::Matrix<double, 3, 3> & m);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -178,22 +178,6 @@ namespace graphics
|
|||
m_offset(0, 0)
|
||||
{}
|
||||
|
||||
StraightTextElement::StraightTextElement(StraightTextElement const & src,
|
||||
math::Matrix<double, 3, 3> const & m)
|
||||
: TextElement(src),
|
||||
m_glyphLayouts(src.m_glyphLayouts)
|
||||
{
|
||||
m_offsets = src.m_offsets;
|
||||
|
||||
setPivot(pivot() * m);
|
||||
|
||||
for (unsigned i = 0; i < m_glyphLayouts.size(); ++i)
|
||||
{
|
||||
m_glyphLayouts[i].setPivot(pivot());
|
||||
m_glyphLayouts[i].setOffset(m_offsets[i]);
|
||||
}
|
||||
}
|
||||
|
||||
vector<m2::AnyRectD> const & StraightTextElement::boundRects() const
|
||||
{
|
||||
if (isDirtyRect())
|
||||
|
@ -262,9 +246,17 @@ namespace graphics
|
|||
m_glyphLayouts[i].setPivot(m_glyphLayouts[i].pivot() + offs);
|
||||
}
|
||||
|
||||
OverlayElement * StraightTextElement::clone(math::Matrix<double, 3, 3> const & m) const
|
||||
void StraightTextElement::setTransformation(const math::Matrix<double, 3, 3> & m)
|
||||
{
|
||||
return new StraightTextElement(*this, m);
|
||||
setPivot(pivot() * getResetMatrix() * m);
|
||||
|
||||
for (unsigned i = 0; i < m_glyphLayouts.size(); ++i)
|
||||
{
|
||||
m_glyphLayouts[i].setPivot(pivot());
|
||||
m_glyphLayouts[i].setOffset(m_offsets[i]);
|
||||
}
|
||||
|
||||
TextElement::setTransformation(m);
|
||||
}
|
||||
|
||||
bool StraightTextElement::hasSharpGeometry() const
|
||||
|
|
|
@ -28,7 +28,6 @@ namespace graphics
|
|||
};
|
||||
|
||||
StraightTextElement(Params const & p);
|
||||
StraightTextElement(StraightTextElement const & src, math::Matrix<double, 3, 3> const & m);
|
||||
|
||||
vector<m2::AnyRectD> const & boundRects() const;
|
||||
|
||||
|
@ -36,7 +35,7 @@ namespace graphics
|
|||
|
||||
void setPivot(m2::PointD const & pv);
|
||||
|
||||
OverlayElement * clone(math::Matrix<double, 3, 3> const & m) const;
|
||||
void setTransformation(const math::Matrix<double, 3, 3> & m);
|
||||
|
||||
bool hasSharpGeometry() const;
|
||||
};
|
||||
|
|
|
@ -30,14 +30,6 @@ namespace graphics
|
|||
m_symbolRect = res->m_texRect;
|
||||
}
|
||||
|
||||
SymbolElement::SymbolElement(SymbolElement const & se, math::Matrix<double, 3, 3> const & m)
|
||||
: base_t(se),
|
||||
m_info(se.m_info),
|
||||
m_symbolRect(se.m_symbolRect)
|
||||
{
|
||||
setPivot(se.pivot() * m);
|
||||
}
|
||||
|
||||
vector<m2::AnyRectD> const & SymbolElement::boundRects() const
|
||||
{
|
||||
if (isDirtyRect())
|
||||
|
@ -101,9 +93,10 @@ namespace graphics
|
|||
res->m_pipelineID);
|
||||
}
|
||||
|
||||
OverlayElement * SymbolElement::clone(math::Matrix<double, 3, 3> const & m) const
|
||||
void SymbolElement::setTransformation(const math::Matrix<double, 3, 3> & m)
|
||||
{
|
||||
return new SymbolElement(*this, m);
|
||||
setPivot(pivot() * getResetMatrix() * m);
|
||||
base_t::setTransformation(m);
|
||||
}
|
||||
|
||||
bool SymbolElement::hasSharpGeometry() const
|
||||
|
|
|
@ -31,15 +31,14 @@ namespace graphics
|
|||
};
|
||||
|
||||
SymbolElement(Params const & p);
|
||||
SymbolElement(SymbolElement const & se, math::Matrix<double, 3, 3> const & m);
|
||||
|
||||
vector<m2::AnyRectD> const & boundRects() const;
|
||||
void draw(OverlayRenderer * s, math::Matrix<double, 3, 3> const & m) const;
|
||||
|
||||
uint32_t resID() const;
|
||||
|
||||
OverlayElement * clone(math::Matrix<double, 3, 3> const & m) const;
|
||||
|
||||
bool hasSharpGeometry() const;
|
||||
|
||||
void setTransformation(const math::Matrix<double, 3, 3> & m);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -84,11 +84,6 @@ namespace gui
|
|||
}
|
||||
}
|
||||
|
||||
graphics::OverlayElement * Element::clone(math::Matrix<double, 3, 3> const & m) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Element::draw(graphics::OverlayRenderer *r, math::Matrix<double, 3, 3> const & m) const
|
||||
{
|
||||
for (unsigned i = 0; i < boundRects().size(); ++i)
|
||||
|
@ -125,4 +120,7 @@ namespace gui
|
|||
m_controller = controller;
|
||||
}
|
||||
|
||||
void Element::setTransformation(const math::Matrix<double, 3, 3> & /*m*/)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,9 +86,9 @@ namespace gui
|
|||
/// check if the layout of element is dirty and re-layout element if needed.
|
||||
void checkDirtyLayout() const;
|
||||
|
||||
graphics::OverlayElement * clone(math::Matrix<double, 3, 3> const & m) const;
|
||||
void draw(graphics::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const;
|
||||
double priority() const;
|
||||
|
||||
void setTransformation(const math::Matrix<double, 3, 3> & m);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue