separated benchmarking code into Framework ancestor.

This commit is contained in:
rachytski 2011-07-16 19:56:15 +03:00 committed by Alex Zolotarev
parent cec98bb6b9
commit 8f3040e62c
11 changed files with 1036 additions and 921 deletions

301
map/benchmark_framework.cpp Normal file
View file

@ -0,0 +1,301 @@
#include "../base/SRC_FIRST.hpp"
#include "benchmark_framework.hpp"
#include "benchmark_provider.hpp"
#include "feature_vec_model.hpp"
#include "../coding/file_container.hpp"
#include "../std/fstream.hpp"
#include "../platform/settings.hpp"
#include "../version/version.hpp"
#include "tiling_render_policy_st.hpp"
template <class T> class DoGetBenchmarks
{
set<string> m_processed;
vector<T> & m_benchmarks;
Platform & m_pl;
public:
DoGetBenchmarks(vector<T> & benchmarks)
: m_benchmarks(benchmarks), m_pl(GetPlatform())
{
}
void operator() (vector<string> const & v)
{
T b;
b.m_name = v[1];
m2::RectD r;
if (m_processed.insert(v[0]).second)
{
try
{
feature::DataHeader header;
header.Load(FilesContainerR(m_pl.GetReader(v[0])).GetReader(HEADER_FILE_TAG));
r = header.GetBounds();
}
catch (RootException const & e)
{
LOG(LINFO, ("Cannot add ", v[0], " file to benchmark: ", e.what()));
return;
}
}
int lastScale;
if (v.size() > 3)
{
double x0, y0, x1, y1;
strings::to_double(v[2], x0);
strings::to_double(v[3], y0);
strings::to_double(v[4], x1);
strings::to_double(v[5], y1);
r = m2::RectD(x0, y0, x1, y1);
strings::to_int(v[6], lastScale);
}
else
strings::to_int(v[2], lastScale);
ASSERT ( r != m2::RectD::GetEmptyRect(), (r) );
b.m_provider.reset(new BenchmarkRectProvider(scales::GetScaleLevel(r), r, lastScale));
m_benchmarks.push_back(b);
}
};
template <class ToDo>
void ForEachBenchmarkRecord(ToDo & toDo)
{
Platform & pl = GetPlatform();
string buffer;
try
{
string configPath;
Settings::Get("BenchmarkConfig", configPath);
ReaderPtr<Reader>(pl.GetReader(configPath)).ReadAsString(buffer);
}
catch (RootException const & e)
{
LOG(LERROR, ("Error reading benchmarks: ", e.what()));
return;
}
istringstream stream(buffer);
string line;
while (stream.good())
{
getline(stream, line);
vector<string> parts;
strings::SimpleTokenizer it(line, " ");
while (it)
{
parts.push_back(*it);
++it;
}
if (!parts.empty())
toDo(parts);
}
}
class FirstReaderAdder : public ReadersAdder
{
typedef ReadersAdder base_type;
public:
FirstReaderAdder(maps_list_t & lst) : base_type(GetPlatform(), lst) {}
void operator() (vector<string> const & v)
{
base_type::operator() (v[0]);
}
};
template <typename TModel>
void BenchmarkFramework<TModel>::EnumLocalMaps(typename base_type::maps_list_t & filesList)
{
FirstReaderAdder adder(filesList);
ForEachBenchmarkRecord(adder);
}
template <typename TModel>
BenchmarkFramework<TModel>::BenchmarkFramework(shared_ptr<WindowHandle> const & wh,
size_t bottomShift)
: base_type(wh, bottomShift),
m_paintDuration(0),
m_maxDuration(0),
m_isBenchmarkInitialized(false)
{
base_type::SetRenderPolicy(make_shared_ptr(new TilingRenderPolicyST(wh, bind(&base_type::DrawModel, this, _1, _2, _3, _4))));
m_startTime = my::FormatCurrentTime();
#ifdef DEBUG
base_type::m_informationDisplay.enableGlobalRect(false);
#endif
base_type::m_informationDisplay.enableBenchmarkInfo(true);
}
template <typename TModel>
void BenchmarkFramework<TModel>::BenchmarkCommandFinished()
{
double duration = m_paintDuration;
if (duration > m_maxDuration)
{
m_maxDuration = duration;
m_maxDurationRect = m_curBenchmarkRect;
base_type::m_informationDisplay.addBenchmarkInfo("maxDurationRect: ", m_maxDurationRect, m_maxDuration);
}
BenchmarkResult res;
res.m_name = m_benchmarks[m_curBenchmark].m_name;
res.m_rect = m_curBenchmarkRect;
res.m_time = duration;
m_benchmarkResults.push_back(res);
if (m_benchmarkResults.size() > 100)
SaveBenchmarkResults();
m_paintDuration = 0;
NextBenchmarkCommand();
}
template <typename TModel>
void BenchmarkFramework<TModel>::SaveBenchmarkResults()
{
string resultsPath;
Settings::Get("BenchmarkResults", resultsPath);
LOG(LINFO, (resultsPath));
ofstream fout(GetPlatform().WritablePathForFile(resultsPath).c_str(), ios::app);
for (size_t i = 0; i < m_benchmarkResults.size(); ++i)
{
fout << GetPlatform().DeviceID() << " "
<< VERSION_STRING << " "
<< m_startTime << " "
<< m_benchmarkResults[i].m_name << " "
<< m_benchmarkResults[i].m_rect.minX() << " "
<< m_benchmarkResults[i].m_rect.minY() << " "
<< m_benchmarkResults[i].m_rect.maxX() << " "
<< m_benchmarkResults[i].m_rect.maxY() << " "
<< m_benchmarkResults[i].m_time << endl;
}
m_benchmarkResults.clear();
}
template <typename TModel>
void BenchmarkFramework<TModel>::SendBenchmarkResults()
{
// ofstream fout(GetPlatform().WritablePathForFile("benchmarks/results.txt").c_str(), ios::app);
// fout << "[COMPLETED]";
// fout.close();
/// send to server for adding to statistics graphics
/// and delete results file
}
template <typename TModel>
void BenchmarkFramework<TModel>::MarkBenchmarkResultsEnd()
{
string resultsPath;
Settings::Get("BenchmarkResults", resultsPath);
LOG(LINFO, (resultsPath));
ofstream fout(GetPlatform().WritablePathForFile(resultsPath).c_str(), ios::app);
fout << "END " << m_startTime << endl;
}
template <typename TModel>
void BenchmarkFramework<TModel>::MarkBenchmarkResultsStart()
{
string resultsPath;
Settings::Get("BenchmarkResults", resultsPath);
LOG(LINFO, (resultsPath));
ofstream fout(GetPlatform().WritablePathForFile(resultsPath).c_str(), ios::app);
fout << "START " << m_startTime << endl;
}
template <typename TModel>
void BenchmarkFramework<TModel>::NextBenchmarkCommand()
{
if ((m_benchmarks[m_curBenchmark].m_provider->hasRect()) || (++m_curBenchmark < m_benchmarks.size()))
{
m_curBenchmarkRect = m_benchmarks[m_curBenchmark].m_provider->nextRect();
base_type::m_navigator.SetFromRect(m_curBenchmarkRect);
base_type::Invalidate();
}
else
{
static bool isFirstTime = true;
if (isFirstTime)
{
isFirstTime = false;
SaveBenchmarkResults();
MarkBenchmarkResultsEnd();
SendBenchmarkResults();
LOG(LINFO, ("Bechmarks took ", m_benchmarksTimer.ElapsedSeconds(), " seconds to complete"));
}
}
}
template <typename TModel>
void BenchmarkFramework<TModel>::InitBenchmark()
{
DoGetBenchmarks<Benchmark> doGet(m_benchmarks);
ForEachBenchmarkRecord(doGet);
m_curBenchmark = 0;
//base_type::m_renderPolicy->addAfterFrame(bind(&this_type::BenchmarkCommandFinished, this));
m_benchmarksTimer.Reset();
MarkBenchmarkResultsStart();
NextBenchmarkCommand();
base_type::Invalidate();
}
template <typename TModel>
void BenchmarkFramework<TModel>::OnSize(int w, int h)
{
Framework<TModel>::OnSize(w, h);
if (!m_isBenchmarkInitialized)
{
m_isBenchmarkInitialized = true;
InitBenchmark();
}
}
template <typename TModel>
void BenchmarkFramework<TModel>::Paint(shared_ptr<PaintEvent> e)
{
/* m2::PointD const center = base_type::m_renderQueue.renderState().m_actualScreen.ClipRect().Center();
base_type::m_informationDisplay.setScreen(m_renderQueue.renderState().m_actualScreen);
base_type::m_informationDisplay.setCenter(m2::PointD(MercatorBounds::XToLon(center.x), MercatorBounds::YToLat(center.y)));
if (!m_isBenchmarkInitialized)
{
e->drawer()->screen()->beginFrame();
e->drawer()->screen()->clear(base_type::m_renderPolicy->bgColor());
base_type::m_informationDisplay.setDisplayRect(m2::RectI(0, 0, 100, 100));
base_type::m_informationDisplay.enableRuler(false);
base_type::m_informationDisplay.doDraw(e->drawer().get());
e->drawer()->screen()->endFrame();
}
else*/
double s = m_benchmarksTimer.ElapsedSeconds();
Framework<TModel>::Paint(e);
m_paintDuration += m_benchmarksTimer.ElapsedSeconds() - s;
BenchmarkCommandFinished();
}
template class BenchmarkFramework<model::FeaturesFetcher>;

View file

@ -0,0 +1,74 @@
#pragma once
#include "framework.hpp"
#include "../geometry/rect2d.hpp"
#include "../base/timer.hpp"
#include "../std/string.hpp"
#include "../std/vector.hpp"
#include "../std/shared_ptr.hpp"
#include "../search/engine.hpp"
class BenchmarkRectProvider;
class WindowHandle;
class PaintEvent;
template <typename TModel>
class BenchmarkFramework : public Framework<TModel>
{
private:
typedef Framework<TModel> base_type;
double m_paintDuration;
double m_maxDuration;
m2::RectD m_maxDurationRect;
m2::RectD m_curBenchmarkRect;
string m_startTime;
struct BenchmarkResult
{
string m_name;
m2::RectD m_rect;
double m_time;
};
vector<BenchmarkResult> m_benchmarkResults;
my::Timer m_benchmarksTimer;
struct Benchmark
{
shared_ptr<BenchmarkRectProvider> m_provider;
string m_name;
};
vector<Benchmark> m_benchmarks;
size_t m_curBenchmark;
bool m_isBenchmarkInitialized;
void BenchmarkCommandFinished();
void NextBenchmarkCommand();
void SaveBenchmarkResults();
void SendBenchmarkResults();
void MarkBenchmarkResultsStart();
void MarkBenchmarkResultsEnd();
void InitBenchmark();
void EnumLocalMaps(typename base_type::maps_list_t & filesList);
public:
BenchmarkFramework(shared_ptr<WindowHandle> const & wh,
size_t bottomShift);
void OnSize(int w, int h);
virtual void Paint(shared_ptr<PaintEvent> e);
};

File diff suppressed because it is too large Load diff

View file

@ -43,6 +43,7 @@
#include "../std/shared_ptr.hpp"
#include "../std/target_os.hpp"
#include "../search/engine.hpp"
//#define DRAW_TOUCH_POINTS
@ -58,15 +59,45 @@ typedef function<void (void)> LocationRetrievedCallbackT;
class DrawerYG;
class RenderPolicy;
struct PathAppender
{
string const & m_path;
PathAppender(string const & path) : m_path(path) {}
void operator()(string & elem)
{
elem.insert(elem.begin(), m_path.begin(), m_path.end());
}
};
class ReadersAdder
{
protected:
typedef vector<string> maps_list_t;
private:
Platform & m_pl;
maps_list_t & m_lst;
public:
ReadersAdder(Platform & pl, maps_list_t & lst) : m_pl(pl), m_lst(lst) {}
void operator() (string const & name)
{
m_lst.push_back(name);
}
};
template
<
class TModel
>
class FrameWork
class Framework
{
protected:
typedef TModel model_t;
typedef FrameWork<model_t> this_type;
typedef Framework<model_t> this_type;
scoped_ptr<search::Engine> m_pSearchEngine;
model_t m_model;
@ -75,10 +106,6 @@ class FrameWork
shared_ptr<WindowHandle> m_windowHandle;
shared_ptr<RenderPolicy> m_renderPolicy;
bool m_isBenchmarking;
bool m_isBenchmarkInitialized;
shared_ptr<yg::ResourceManager> m_resourceManager;
InformationDisplay m_informationDisplay;
double const m_metresMinWidth;
@ -97,43 +124,10 @@ class FrameWork
mutable threads::Mutex m_modelSyn;
double m_maxDuration;
m2::RectD m_maxDurationRect;
m2::RectD m_curBenchmarkRect;
int m_tileSize;
struct BenchmarkResult
{
string m_name;
m2::RectD m_rect;
double m_time;
};
vector<BenchmarkResult> m_benchmarkResults;
my::Timer m_benchmarksTimer;
string m_startTime;
my::Timer m_timer;
struct Benchmark
{
shared_ptr<BenchmarkRectProvider> m_provider;
string m_name;
};
vector<Benchmark> m_benchmarks;
size_t m_curBenchmark;
yg::Tiler m_tiler;
void BenchmarkCommandFinished();
// void NextBenchmarkCommand();
void SaveBenchmarkResults();
void SendBenchmarkResults();
void MarkBenchmarkResultsStart();
void MarkBenchmarkResultsEnd();
typedef typename TModel::ReaderT ReaderT;
void AddMap(string const & file);
@ -143,12 +137,11 @@ class FrameWork
void OnCompassUpdate(location::CompassInfo const & info);
public:
FrameWork(shared_ptr<WindowHandle> windowHandle,
size_t bottomShift);
~FrameWork();
void SetRenderPolicy(shared_ptr<RenderPolicy> const & rp);
void InitBenchmark();
public:
Framework(shared_ptr<WindowHandle> windowHandle,
size_t bottomShift);
void initializeGL(shared_ptr<yg::gl::RenderContext> const & primaryContext,
shared_ptr<yg::ResourceManager> const & resourceManager);
@ -156,8 +149,7 @@ public:
model_t & get_model();
typedef vector<string> maps_list_t;
void EnumLocalMaps(maps_list_t & filesList);
void EnumBenchmarkMaps(maps_list_t & filesList);
virtual void EnumLocalMaps(maps_list_t & filesList);
/// Initialization.
template <class TStorage>
@ -166,16 +158,14 @@ public:
m_model.InitClassificator();
typename TStorage::TEnumMapsFunction enumMapsFn;
if (m_isBenchmarking)
enumMapsFn = bind(&FrameWork::EnumBenchmarkMaps, this, _1);
else
enumMapsFn = bind(&FrameWork::EnumLocalMaps, this, _1);
enumMapsFn = bind(&Framework::EnumLocalMaps, this, _1);
LOG(LINFO, ("Initializing storage"));
// initializes model with locally downloaded maps
storage.Init(bind(&FrameWork::AddMap, this, _1),
bind(&FrameWork::RemoveMap, this, _1),
bind(&FrameWork::InvalidateRect, this, _1),
storage.Init(bind(&Framework::AddMap, this, _1),
bind(&Framework::RemoveMap, this, _1),
bind(&Framework::InvalidateRect, this, _1),
enumMapsFn);
LOG(LINFO, ("Storage initialized"));
}
@ -192,6 +182,11 @@ public:
public:
void DrawModel(shared_ptr<PaintEvent> e,
ScreenBase const & screen,
m2::RectD const & selectRect,
int scaleLevel);
void Search(string const & text, SearchCallbackT callback);
void SetMaxWorldRect();
@ -203,7 +198,7 @@ public:
bool LoadState();
/// Resize event from window.
void OnSize(int w, int h);
virtual void OnSize(int w, int h);
bool SetUpdatesEnabled(bool doEnable);
@ -212,16 +207,8 @@ public:
double GetCurrentScale() const;
/// Actual rendering function.
/// Called, as the renderQueue processes RenderCommand
/// Usually it happens in the separate thread.
void PaintImpl(shared_ptr<PaintEvent> e,
ScreenBase const & screen,
m2::RectD const & selectRect,
int scaleLevel);
/// Function for calling from platform dependent-paint function.
void Paint(shared_ptr<PaintEvent> e);
virtual void Paint(shared_ptr<PaintEvent> e);
void CenterViewport(m2::PointD const & pt);
@ -257,3 +244,4 @@ public:
void StopScale(ScaleEvent const & e);
//@}
};

18
map/framework_factory.cpp Normal file
View file

@ -0,0 +1,18 @@
#include "../base/SRC_FIRST.hpp"
#include "framework_factory.hpp"
#include "benchmark_framework.hpp"
#include "feature_vec_model.hpp"
#include "../platform/platform.hpp"
template <typename TModel>
Framework<TModel> * FrameworkFactory<TModel>::CreateFramework(shared_ptr<WindowHandle> const & wh, size_t bottomShift)
{
if (GetPlatform().IsBenchmarking())
return new BenchmarkFramework<TModel>(wh, bottomShift);
else
return new Framework<TModel>(wh, bottomShift);
}
template class FrameworkFactory<model::FeaturesFetcher>;

13
map/framework_factory.hpp Normal file
View file

@ -0,0 +1,13 @@
#pragma once
#include "framework.hpp"
#include "../std/shared_ptr.hpp"
class WindowHandle;
template <typename TModel>
class FrameworkFactory
{
public:
static Framework<TModel> * CreateFramework(shared_ptr<WindowHandle> const & wh, size_t bottomShift);
};

View file

@ -27,7 +27,9 @@ HEADERS += \
render_policy.hpp \
tiling_render_policy_mt.hpp \
tiling_render_policy_st.hpp \
tiling_render_policy.hpp
tiling_render_policy.hpp \
benchmark_framework.hpp \
framework_factory.hpp
SOURCES += \
feature_vec_model.cpp \
@ -44,7 +46,9 @@ SOURCES += \
render_policy.cpp \
tiling_render_policy_mt.cpp \
tiling_render_policy_st.cpp \
tiling_render_policy.cpp
tiling_render_policy.cpp \
benchmark_framework.cpp \
framework_factory.cpp
!iphone*:!bada*:!android* {
HEADERS += qgl_render_context.hpp

View file

@ -53,5 +53,4 @@ public:
/// initialize render policy
virtual void initialize(shared_ptr<yg::gl::RenderContext> const & primaryContext,
shared_ptr<yg::ResourceManager> const & resourceManager) = 0;
};

View file

@ -107,7 +107,7 @@ bool BasePlatformImpl::IsBenchmarking() const
bool res = false;
(void)Settings::Get("IsBenchmarking", res);
#ifndef OMIM_PRODUCTION
/*#ifndef OMIM_PRODUCTION
if (res)
{
static bool first = true;
@ -118,7 +118,7 @@ bool BasePlatformImpl::IsBenchmarking() const
}
res = false;
}
#endif
#endif*/
return res;
}

View file

@ -8,9 +8,9 @@
#include <QtGui/QMouseEvent>
#include "../map/framework_factory.hpp"
#include "../base/start_mem_debug.hpp"
using namespace storage;
namespace qt
@ -18,19 +18,19 @@ namespace qt
DrawWidget::DrawWidget(QWidget * pParent, Storage & storage)
: base_type(pParent),
m_handle(new qt::WindowHandle(this)),
m_framework(m_handle, 0),
m_framework(FrameworkFactory<model_t>::CreateFramework(m_handle, 0)),
m_isDrag(false),
m_redrawInterval(100),
m_pScale(0)
{
m_framework.InitStorage(storage);
m_framework->InitStorage(storage);
m_timer = new QTimer(this);
connect(m_timer, SIGNAL(timeout()), this, SLOT(ScaleTimerElapsed()));
}
void DrawWidget::PrepareShutdown()
{
m_framework.PrepareToShutdown();
m_framework->PrepareToShutdown();
}
void DrawWidget::SetScaleControl(QScaleSlider * pScale)
@ -42,7 +42,7 @@ namespace qt
void DrawWidget::UpdateNow()
{
m_framework.Invalidate();
m_framework->Invalidate();
}
bool DrawWidget::LoadState()
@ -51,9 +51,9 @@ namespace qt
if (!Settings::Get("DrawWidgetSize", widthAndHeight))
return false;
m_framework.OnSize(widthAndHeight.first, widthAndHeight.second);
m_framework->OnSize(widthAndHeight.first, widthAndHeight.second);
if (!m_framework.LoadState())
if (!m_framework->LoadState())
return false;
//m_framework.UpdateNow();
@ -66,7 +66,7 @@ namespace qt
pair<int, int> widthAndHeight(width(), height());
Settings::Set("DrawWidgetSize", widthAndHeight);
m_framework.SaveState();
m_framework->SaveState();
}
//void DrawWidget::ShowFeature(Feature const & p)
@ -76,76 +76,76 @@ namespace qt
void DrawWidget::OnEnableMyPosition(LocationRetrievedCallbackT observer)
{
m_framework.StartLocationService(observer);
m_framework->StartLocationService(observer);
}
void DrawWidget::OnDisableMyPosition()
{
m_framework.StopLocationService();
m_framework->StopLocationService();
}
void DrawWidget::MoveLeft()
{
m_framework.Move(math::pi, 0.5);
m_framework->Move(math::pi, 0.5);
emit ViewportChanged();
}
void DrawWidget::MoveRight()
{
m_framework.Move(0.0, 0.5);
m_framework->Move(0.0, 0.5);
emit ViewportChanged();
}
void DrawWidget::MoveUp()
{
m_framework.Move(math::pi/2.0, 0.5);
m_framework->Move(math::pi/2.0, 0.5);
emit ViewportChanged();
}
void DrawWidget::MoveDown()
{
m_framework.Move(-math::pi/2.0, 0.5);
m_framework->Move(-math::pi/2.0, 0.5);
emit ViewportChanged();
}
void DrawWidget::ScalePlus()
{
m_framework.Scale(2.0);
m_framework->Scale(2.0);
UpdateScaleControl();
emit ViewportChanged();
}
void DrawWidget::ScaleMinus()
{
m_framework.Scale(0.5);
m_framework->Scale(0.5);
UpdateScaleControl();
emit ViewportChanged();
}
void DrawWidget::ScalePlusLight()
{
m_framework.Scale(1.5);
m_framework->Scale(1.5);
UpdateScaleControl();
emit ViewportChanged();
}
void DrawWidget::ScaleMinusLight()
{
m_framework.Scale(2.0/3.0);
m_framework->Scale(2.0/3.0);
UpdateScaleControl();
emit ViewportChanged();
}
void DrawWidget::ShowAll()
{
m_framework.ShowAll();
m_framework->ShowAll();
UpdateScaleControl();
emit ViewportChanged();
}
void DrawWidget::Repaint()
{
m_framework.Invalidate();
m_framework->Invalidate();
}
void DrawWidget::ScaleChanged(int action)
@ -155,7 +155,7 @@ namespace qt
double const factor = m_pScale->GetScaleFactor();
if (factor != 1.0)
{
m_framework.Scale(factor);
m_framework->Scale(factor);
emit ViewportChanged();
}
}
@ -166,19 +166,19 @@ namespace qt
widget_type::initializeGL();
m_handle->setRenderContext(renderContext());
//m_handle->setDrawer(GetDrawer());
m_framework.initializeGL(renderContext(), resourceManager());
m_framework->initializeGL(renderContext(), resourceManager());
}
void DrawWidget::DoDraw(shared_ptr<drawer_t> p)
{
shared_ptr<PaintEvent> paintEvent(new PaintEvent(p));
m_framework.Paint(paintEvent);
m_framework->Paint(paintEvent);
}
void DrawWidget::DoResize(int w, int h)
{
m_framework.OnSize(w, h);
m_framework.Invalidate();
m_framework->OnSize(w, h);
m_framework->Invalidate();
UpdateScaleControl();
emit ViewportChanged();
}
@ -198,7 +198,7 @@ namespace qt
if (e->button() == Qt::LeftButton)
{
m_framework.StartDrag(get_drag_event(e));
m_framework->StartDrag(get_drag_event(e));
setCursor(Qt::CrossCursor);
m_isDrag = true;
@ -213,7 +213,7 @@ namespace qt
{
StopDragging(e);
m_framework.ScaleToPoint(ScaleToPointEvent(e->pos().x(), e->pos().y(), 1.5));
m_framework->ScaleToPoint(ScaleToPointEvent(e->pos().x(), e->pos().y(), 1.5));
UpdateScaleControl();
emit ViewportChanged();
@ -225,7 +225,7 @@ namespace qt
base_type::mouseMoveEvent(e);
if (m_isDrag)
m_framework.DoDrag(get_drag_event(e));
m_framework->DoDrag(get_drag_event(e));
}
void DrawWidget::mouseReleaseEvent(QMouseEvent * e)
@ -240,7 +240,7 @@ namespace qt
{
if (m_isDrag && e->button() == Qt::LeftButton)
{
m_framework.StopDrag(get_drag_event(e));
m_framework->StopDrag(get_drag_event(e));
setCursor(Qt::ArrowCursor);
m_isDrag = false;
@ -261,8 +261,8 @@ namespace qt
m_timer->stop();
m_timer->start(m_redrawInterval);
//m_framework.Scale(exp(e->delta() / 360.0));
m_framework.ScaleToPoint(ScaleToPointEvent(e->pos().x(), e->pos().y(), exp(e->delta() / 360.0)));
//m_framework->Scale(exp(e->delta() / 360.0));
m_framework->ScaleToPoint(ScaleToPointEvent(e->pos().x(), e->pos().y(), exp(e->delta() / 360.0)));
UpdateScaleControl();
emit ViewportChanged();
}
@ -273,18 +273,18 @@ namespace qt
if (m_pScale)
{
// don't send ScaleChanged
m_pScale->SetPosWithBlockedSignals(m_framework.GetCurrentScale());
m_pScale->SetPosWithBlockedSignals(m_framework->GetCurrentScale());
}
}
void DrawWidget::Search(const string & text, SearchCallbackT callback)
{
m_framework.Search(text, callback);
m_framework->Search(text, callback);
}
void DrawWidget::ShowFeature(m2::RectD const & rect)
{
m_framework.ShowRect(rect);
m_framework->ShowRect(rect);
UpdateScaleControl();
}
}

View file

@ -7,6 +7,8 @@
#include "../map/framework.hpp"
#include "../map/navigator.hpp"
#include "../std/auto_ptr.hpp"
#include <QtCore/QTimer>
//class FileReader;
@ -30,7 +32,7 @@ namespace qt
typedef model::FeaturesFetcher model_t;
FrameWork<model_t> m_framework;
auto_ptr<Framework<model_t> > m_framework;
bool m_isDrag;