detecting empty model and displaying information message accordingly.

This commit is contained in:
rachytski 2011-03-31 01:49:54 +03:00 committed by Alex Zolotarev
parent b7942c0c9c
commit f4a6f3e31f
9 changed files with 68 additions and 8 deletions

View file

@ -39,12 +39,14 @@ namespace fwork
DrawProcessor::DrawProcessor( m2::RectD const & r,
ScreenBase const & convertor,
shared_ptr<PaintEvent> paintEvent,
int scaleLevel)
shared_ptr<PaintEvent> const & paintEvent,
int scaleLevel,
shared_ptr<yg::gl::RenderState> const & renderState)
: m_rect(r),
m_convertor(convertor),
m_paintEvent(paintEvent),
m_zoom(scaleLevel)
m_zoom(scaleLevel),
m_renderState(renderState)
#ifdef PROFILER_DRAWING
, m_drawCount(0)
#endif
@ -118,6 +120,8 @@ namespace fwork
return true;
}
m_renderState->m_isEmptyModelCurrent = false;
shared_ptr<di::DrawInfo> ptr(new di::DrawInfo(f.GetName()));
using namespace get_pts;

View file

@ -61,6 +61,7 @@ namespace fwork
vector<drule::Key> m_keys;
int m_zoom;
shared_ptr<yg::gl::RenderState> m_renderState;
#ifdef PROFILER_DRAWING
size_t m_drawCount;
@ -73,11 +74,12 @@ namespace fwork
static const int reserve_rules_count = 16;
public:
DrawProcessor(m2::RectD const & r,
ScreenBase const & convertor,
shared_ptr<PaintEvent> paintEvent,
int scaleLevel);
shared_ptr<PaintEvent> const & paintEvent,
int scaleLevel,
shared_ptr<yg::gl::RenderState> const & renderState);
bool operator() (FeatureType const & f);
};
@ -360,7 +362,8 @@ public:
int scaleLevel
)
{
fwork::DrawProcessor doDraw(selectRect, screen, e, scaleLevel);
fwork::DrawProcessor doDraw(selectRect, screen, e, scaleLevel, m_renderQueue.renderStatePtr());
m_renderQueue.renderStatePtr()->m_isEmptyModelCurrent = true;
try
{
@ -448,6 +451,9 @@ public:
OGLCHECK(glTranslatef(-ptShift.x, -ptShift.y, 0));
ScreenBase currentScreen = m_navigator.Screen();
m_informationDisplay.enableEmptyModelMessage(m_renderQueue.renderStatePtr()->m_isEmptyModelActual);
if (m_isBenchmarking)
currentScreen = m_renderQueue.renderState().m_actualScreen;

View file

@ -28,6 +28,7 @@ InformationDisplay::InformationDisplay()
enableMemoryWarning(false);
enableBenchmarkInfo(false);
enableGlobalRect(false);
enableEmptyModelMessage(false);
for (int i = 0; i < sizeof(m_DebugPts) / sizeof(m2::PointD); ++i)
m_DebugPts[i] = m2::PointD(0, 0);
@ -526,6 +527,34 @@ void InformationDisplay::drawLog(DrawerYG * pDrawer)
}
}
void InformationDisplay::enableEmptyModelMessage(bool doEnable)
{
m_isEmptyModelMessageEnabled = doEnable;
}
void InformationDisplay::drawEmptyModelMessage(DrawerYG * pDrawer)
{
m2::PointD pt = m_screen.PixelRect().Center() - m2::PointD(0, m_bottomShift * m_visualScale);
char const s0 [] = "Nothing found. Have you tried downloading maps of the countries?";
char const s1 [] = "Just the button at the bottom right corner to download the maps.";
m2::RectD tr0 = pDrawer->screen()->textRect(s0, 10, true, false);
m2::RectD tr1 = pDrawer->screen()->textRect(s1, 10, true, false);
pDrawer->screen()->drawText(m2::PointD(-tr0.SizeX() / 2, -tr0.SizeY() / 2) + pt,
0, 10, yg::Color(255, 255, 255, 255), s0, true, yg::Color(255, 255, 255, 255),
yg::maxDepth,
true,
false);
pDrawer->screen()->drawText(m2::PointD(-tr1.SizeX() / 2, -tr1.SizeY() / 2 + tr0.SizeY() + 5) + pt,
0, 10, yg::Color(255, 255, 255, 255), s1, true, yg::Color(255, 255, 255, 255),
yg::maxDepth,
true,
false);
}
void InformationDisplay::enableBenchmarkInfo(bool doEnable)
{
m_isBenchmarkInfoEnabled = doEnable;
@ -625,4 +654,6 @@ void InformationDisplay::doDraw(DrawerYG *drawer)
drawBenchmarkInfo(drawer);
if (s_isLogEnabled)
drawLog(drawer);
if (m_isEmptyModelMessageEnabled)
drawEmptyModelMessage(drawer);
}

View file

@ -52,6 +52,8 @@ private:
bool m_isDebugInfoEnabled;
double m_frameDuration;
bool m_isEmptyModelMessageEnabled;
bool m_isBenchmarkInfoEnabled;
struct BenchmarkInfo
@ -130,5 +132,8 @@ public:
void setLogSize(size_t logSize);
void drawLog(DrawerYG * pDrawer);
void enableEmptyModelMessage(bool doEnable);
void drawEmptyModelMessage(DrawerYG * pDrawer);
static void logMessage(my::LogLevel, my::SrcPoint const &, string const &);
};

View file

@ -83,6 +83,11 @@ yg::gl::RenderState const & RenderQueue::renderState() const
return *m_renderState.get();
}
shared_ptr<yg::gl::RenderState> const & RenderQueue::renderStatePtr() const
{
return m_renderState;
}
void RenderQueue::memoryWarning()
{
m_routine->memoryWarning();

View file

@ -58,6 +58,8 @@ public:
/// copy primary render state
yg::gl::RenderState const CopyState() const;
shared_ptr<yg::gl::RenderState> const & renderStatePtr() const;
yg::gl::RenderState const & renderState() const;
/// free all possible memory caches

View file

@ -12,7 +12,9 @@ namespace yg
: m_backBufferLayers(1),
m_isResized(false),
m_doRepaintAll(false),
m_mutex(new threads::Mutex())
m_mutex(new threads::Mutex()),
m_isEmptyModelActual(false),
m_isEmptyModelCurrent(false)
{}
bool RenderState::isPanning() const

View file

@ -25,6 +25,8 @@ namespace yg
shared_ptr<BaseTexture> m_actualTarget;
/// Screen parameters
ScreenBase m_actualScreen;
/// Empty-model flag
bool m_isEmptyModelActual;
/// @}
/// In-Progress rendering operation params
@ -37,6 +39,8 @@ namespace yg
shared_ptr<RenderBuffer> m_depthBuffer;
/// Duration of the rendering operation
double m_duration;
/// Empty-model flag of the current rendering operation
bool m_isEmptyModelCurrent;
/// @}
/// Surface height and width.

View file

@ -55,6 +55,7 @@ namespace yg
threads::MutexGuard guard(*m_renderState->m_mutex.get());
swap(m_renderState->m_actualTarget, m_renderState->m_backBufferLayers.front());
m_renderState->m_actualScreen = m_renderState->m_currentScreen;
m_renderState->m_isEmptyModelActual = m_renderState->m_isEmptyModelCurrent;
}
/// blitting will be performed through