diff options
author | ExMix <rahuba.youri@mapswithme.com> | 2014-02-07 13:40:39 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:11:21 +0300 |
commit | 488e547e86510d3f7e9676e4784dae1db46378db (patch) | |
tree | 30aa7e132484bfa4a33c8515aba53da21ae5df28 /drape_frontend/drape_engine.cpp | |
parent | dc969a5f4161a3c0775b37becf42aa3e16832fad (diff) |
[drape] simple navigator
Diffstat (limited to 'drape_frontend/drape_engine.cpp')
-rw-r--r-- | drape_frontend/drape_engine.cpp | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/drape_frontend/drape_engine.cpp b/drape_frontend/drape_engine.cpp index dd618f71b9..ee8a63cd16 100644 --- a/drape_frontend/drape_engine.cpp +++ b/drape_frontend/drape_engine.cpp @@ -6,33 +6,76 @@ namespace df { DrapeEngine::DrapeEngine(RefPointer<OGLContextFactory> contextfactory, double vs, Viewport const & viewport) + : m_viewport(viewport) + , m_navigator(m_scales) { GLFunctions::Init(); VizualizationParams::SetVisualScale(vs); + m_scales.SetParams(vs, ScalesProcessor::CalculateTileSize(m_viewport.GetWidth(), m_viewport.GetHeight())); + //m_modelView.Load(); + m_navigator.LoadState(); m_threadCommutator = MasterPointer<ThreadsCommutator>(new ThreadsCommutator()); RefPointer<ThreadsCommutator> commutatorRef = m_threadCommutator.GetRefPointer(); - m_frontend = MasterPointer<FrontendRenderer>(new FrontendRenderer(commutatorRef, contextfactory, viewport)); - m_backend = MasterPointer<BackendRenderer>(new BackendRenderer(commutatorRef, contextfactory, viewport)); + m_frontend = MasterPointer<FrontendRenderer>(new FrontendRenderer(commutatorRef, contextfactory, m_viewport)); + m_backend = MasterPointer<BackendRenderer>(new BackendRenderer(commutatorRef, contextfactory, m_viewport)); + + UpdateCoverage(); } DrapeEngine::~DrapeEngine() { + //m_modelView.Save(); + m_navigator.SaveState(); m_backend.Destroy(); m_frontend.Destroy(); m_threadCommutator.Destroy(); } - void DrapeEngine::OnSizeChanged(int x0, int y0, int w, int h) + void DrapeEngine::Resize(int w, int h) { + if (m_viewport.GetWidth() == w && m_viewport.GetHeight() == h) + return; + + //m_modelView.Resize(w, h); + m_viewport.SetViewport(0, 0, w, h); + m_navigator.OnSize(0, 0, w, h); m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, - MovePointer<Message>(new ResizeMessage(x0, y0, w, h))); + MovePointer<Message>(new ResizeMessage(m_viewport))); + UpdateCoverage(); + } + + void DrapeEngine::DragStarted(const m2::PointF & p) + { + //m_modelView.DrawStarted(p); + m_navigator.StartDrag(p, 0.0); + UpdateCoverage(); + } + + void DrapeEngine::Drag(m2::PointF const & p) + { + //m_modelView.Drag(p); + m_navigator.DoDrag(p, 0.0); + UpdateCoverage(); + } + + void DrapeEngine::DragEnded(m2::PointF const & p) + { + //m_modelView.DragEnded(p); + m_navigator.StopDrag(p, 0.0, false); + UpdateCoverage(); + } + + void DrapeEngine::Scale(const m2::PointF & p, double factor) + { + m_navigator.ScaleToPoint(p, factor, 0.0); + UpdateCoverage(); } - void DrapeEngine::SetAngle(float radians) + void DrapeEngine::UpdateCoverage() { m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, - MovePointer<Message>(new RotateMessage(radians))); + MovePointer<Message>(new UpdateCoverageMessage(m_navigator.Screen()))); } } |