[core] remove useless code

This commit is contained in:
ExMix 2014-10-08 10:35:23 +03:00 committed by Alex Zolotarev
parent 943dc568bc
commit b0a390f194
4 changed files with 15 additions and 232 deletions

View file

@ -143,7 +143,6 @@ BenchmarkEngine::BenchmarkEngine(Framework * fw)
m_maxDuration(0),
m_framework(fw)
{
// m_framework->GetInformationDisplay().enableBenchmarkInfo(true);
}
void BenchmarkEngine::BenchmarkCommandFinished()
@ -154,7 +153,6 @@ void BenchmarkEngine::BenchmarkCommandFinished()
{
m_maxDuration = duration;
m_maxDurationRect = m_curBenchmarkRect;
m_framework->GetInformationDisplay().addBenchmarkInfo("maxDurationRect: ", m_maxDurationRect, m_maxDuration);
}
BenchmarkResult res;

View file

@ -33,7 +33,6 @@ namespace
InformationDisplay::InformationDisplay(Framework * fw)
: m_framework(fw)
, m_visualScale(1)
{
m_fontDesc.m_color = Color(0x4D, 0x4D, 0x4D, 0xCC);
@ -44,19 +43,11 @@ InformationDisplay::InformationDisplay(Framework * fw)
InitDebugLabel();
InitCopyright(fw);
enableDebugPoints(false);
#ifdef DEBUG
enableDebugInfo(false);
enableMemoryWarning(false);
enableBenchmarkInfo(false);
enableCountryStatusDisplay(false);
#endif
m_compassArrow->setIsVisible(false);
m_ruler->setIsVisible(false);
for (size_t i = 0; i < ARRAY_SIZE(m_DebugPts); ++i)
m_DebugPts[i] = m2::PointD(0, 0);
setVisualScale(m_visualScale);
setVisualScale(1);
}
void InformationDisplay::InitRuler(Framework * fw)
@ -68,6 +59,7 @@ void InformationDisplay::InitRuler(Framework * fw)
p.m_framework = fw;
m_ruler.reset(new Ruler(p));
m_ruler->setIsVisible(false);
}
void InformationDisplay::InitCountryStatusDisplay(Framework * fw)
@ -104,6 +96,7 @@ void InformationDisplay::InitCompassArrow(Framework * fw)
p.m_framework = fw;
m_compassArrow.reset(new CompassArrow(p));
m_compassArrow->setIsVisible(false);
}
void InformationDisplay::InitLocationState(Framework * fw)
@ -158,45 +151,24 @@ void InformationDisplay::setController(gui::Controller * controller)
void InformationDisplay::setDisplayRect(m2::RectI const & rect)
{
m_displayRect = rect;
double visualScale = m_framework->GetVisualScale();
m_countryStatusDisplay->setPivot(m2::PointD(rect.Center()));
m2::PointD const size = m_compassArrow->GetPixelSize();
m_compassArrow->setPivot(m2::PointD(COMPASS_X_OFFSET * m_visualScale + size.x / 2.0,
rect.maxY() - COMPASS_Y_OFFSET * m_visualScale - size.y / 2.0));
m_compassArrow->setPivot(m2::PointD(COMPASS_X_OFFSET * visualScale + size.x / 2.0,
rect.maxY() - COMPASS_Y_OFFSET * visualScale - size.y / 2.0));
m_ruler->setPivot(m2::PointD(rect.maxX() - RULLER_X_OFFSET * m_visualScale,
rect.maxY() - RULLER_Y_OFFSET * m_visualScale));
m_ruler->setPivot(m2::PointD(rect.maxX() - RULLER_X_OFFSET * visualScale,
rect.maxY() - RULLER_Y_OFFSET * visualScale));
if (m_copyrightLabel)
{
m_copyrightLabel->setPivot(m2::PointD(rect.maxX() - RULLER_X_OFFSET * m_visualScale,
rect.maxY() - RULLER_Y_OFFSET * m_visualScale));
m_copyrightLabel->setPivot(m2::PointD(rect.maxX() - RULLER_X_OFFSET * visualScale,
rect.maxY() - RULLER_Y_OFFSET * visualScale));
}
m_debugLabel->setPivot(m2::PointD(rect.minX() + 10,
rect.minY() + 50 + 5 * m_visualScale));
}
void InformationDisplay::enableDebugPoints(bool doEnable)
{
m_isDebugPointsEnabled = doEnable;
}
void InformationDisplay::setDebugPoint(int pos, m2::PointD const & pt)
{
m_DebugPts[pos] = pt;
}
void InformationDisplay::drawDebugPoints(Drawer * pDrawer)
{
for (size_t i = 0; i < ARRAY_SIZE(m_DebugPts); ++i)
if (m_DebugPts[i] != m2::PointD(0, 0))
{
pDrawer->screen()->drawArc(m_DebugPts[i], 0, math::pi * 2, 30, Color(0, 0, 255, 32), debugDepth);
pDrawer->screen()->fillSector(m_DebugPts[i], 0, math::pi * 2, 30, Color(0, 0, 255, 32), debugDepth);
}
rect.minY() + 50 + 5 * visualScale));
}
bool InformationDisplay::isCopyrightActive() const
@ -219,9 +191,7 @@ bool InformationDisplay::isRulerEnabled() const
void InformationDisplay::setVisualScale(double visualScale)
{
m_visualScale = visualScale;
m_fontDesc.m_size = static_cast<uint32_t>(FONT_SIZE * m_visualScale);
m_fontDesc.m_size = static_cast<uint32_t>(FONT_SIZE * visualScale);
m_ruler->setFont(gui::Element::EActive, m_fontDesc);
m_debugLabel->setFont(gui::Element::EActive, m_fontDesc);
@ -242,36 +212,6 @@ void InformationDisplay::setDebugInfo(double frameDuration, int currentScale)
m_debugLabel->setText(out.str());
}
void InformationDisplay::enableMemoryWarning(bool flag)
{
m_isMemoryWarningEnabled = flag;
}
void InformationDisplay::memoryWarning()
{
enableMemoryWarning(true);
m_lastMemoryWarning = my::Timer();
}
void InformationDisplay::drawMemoryWarning(Drawer * drawer)
{
m_yOffset += 20;
m2::PointD pos(m_displayRect.minX() + 10, m_displayRect.minY() + m_yOffset);
ostringstream out;
out << "MemoryWarning : " << m_lastMemoryWarning.ElapsedSeconds() << " sec. ago.";
drawer->screen()->drawText(m_fontDesc,
pos,
EPosAboveRight,
out.str(),
debugDepth,
false);
if (m_lastMemoryWarning.ElapsedSeconds() > 5)
enableMemoryWarning(false);
}
void InformationDisplay::enableCompassArrow(bool doEnable)
{
if (doEnable)
@ -290,79 +230,9 @@ void InformationDisplay::setCompassArrowAngle(double angle)
m_compassArrow->SetAngle(angle);
}
void InformationDisplay::enableCountryStatusDisplay(bool doEnable)
{
m_countryStatusDisplay->setIsVisible(doEnable);
}
void InformationDisplay::setEmptyCountryIndex(storage::TIndex const & idx)
{
m_countryStatusDisplay->setCountryIndex(idx);
}
void InformationDisplay::setDownloadListener(gui::Button::TOnClickListener const & l)
{
m_downloadButton->setOnClickListener(l);
}
void InformationDisplay::enableBenchmarkInfo(bool doEnable)
{
m_isBenchmarkInfoEnabled = doEnable;
}
bool InformationDisplay::addBenchmarkInfo(string const & name, m2::RectD const & globalRect, double frameDuration)
{
BenchmarkInfo info;
info.m_name = name;
info.m_duration = frameDuration;
info.m_rect = globalRect;
m_benchmarkInfo.push_back(info);
return true;
}
void InformationDisplay::drawBenchmarkInfo(Drawer * pDrawer)
{
m_yOffset += 20;
m2::PointD pos(m_displayRect.minX() + 10, m_displayRect.minY() + m_yOffset);
pDrawer->screen()->drawText(m_fontDesc,
pos,
EPosAboveRight,
"benchmark info :",
benchmarkDepth,
false);
size_t const count = m_benchmarkInfo.size();
for (size_t i = (count <= 5 ? 0 : count - 5); i < count; ++i)
{
ostringstream out;
m2::RectD const & r = m_benchmarkInfo[i].m_rect;
out << " " << m_benchmarkInfo[i].m_name
<< ", " << "rect: (" << r.minX()
<< ", " << r.minY()
<< ", " << r.maxX()
<< ", " << r.maxY()
<< "), duration : " << m_benchmarkInfo[i].m_duration;
m_yOffset += 20;
pos.y += 20;
pDrawer->screen()->drawText(m_fontDesc,
pos,
EPosAboveRight,
out.str(),
benchmarkDepth,
false);
}
}
void InformationDisplay::doDraw(Drawer *drawer)
{
m_yOffset = 0;
if (m_isDebugPointsEnabled)
drawDebugPoints(drawer);
if (m_isMemoryWarningEnabled)
drawMemoryWarning(drawer);
if (m_isBenchmarkInfoEnabled)
drawBenchmarkInfo(drawer);
m_countryStatusDisplay->SetCountryIndex(idx);
}
shared_ptr<CountryStatusDisplay> const & InformationDisplay::countryStatusDisplay() const

View file

@ -40,34 +40,9 @@ class InformationDisplay
Framework * m_framework;
graphics::FontDesc m_fontDesc;
m2::RectI m_displayRect;
int m_yOffset;
/// For debugging purposes up to 10 drawable points.
bool m_isDebugPointsEnabled;
m2::PointD m_DebugPts[10];
shared_ptr<Ruler> m_ruler;
shared_ptr<gui::Button> m_downloadButton;
gui::Controller * m_controller;
bool m_isBenchmarkInfoEnabled;
struct BenchmarkInfo
{
string m_name;
m2::RectD m_rect;
double m_duration;
};
vector<BenchmarkInfo> m_benchmarkInfo;
double m_visualScale;
my::Timer m_lastMemoryWarning;
bool m_isMemoryWarningEnabled;
shared_ptr<CountryStatusDisplay> m_countryStatusDisplay;
shared_ptr<CompassArrow> m_compassArrow;
shared_ptr<location::State> m_locationState;
@ -91,10 +66,6 @@ public:
void setDisplayRect(m2::RectI const & rect);
void setVisualScale(double visualScale);
void enableDebugPoints(bool doEnable);
void setDebugPoint(int pos, m2::PointD const & pt);
void drawDebugPoints(Drawer * pDrawer);
bool isCopyrightActive() const;
void enableRuler(bool doEnable);
@ -103,26 +74,14 @@ public:
void enableDebugInfo(bool doEnable);
void setDebugInfo(double frameDuration, int currentScale);
void enableMemoryWarning(bool doEnable);
void memoryWarning();
void drawMemoryWarning(Drawer * pDrawer);
void measurementSystemChanged();
void enableBenchmarkInfo(bool doEnable);
bool addBenchmarkInfo(string const & name, m2::RectD const & globalRect, double frameDuration);
void drawBenchmarkInfo(Drawer * pDrawer);
void doDraw(Drawer * drawer);
void enableCompassArrow(bool doEnable);
bool isCompassArrowEnabled() const;
void setCompassArrowAngle(double angle);
shared_ptr<location::State> const & locationState() const;
void enableCountryStatusDisplay(bool doEnable);
void setDownloadListener(gui::Button::TOnClickListener const & l);
void setEmptyCountryIndex(storage::TIndex const & idx);
shared_ptr<CountryStatusDisplay> const & countryStatusDisplay() const;

View file

@ -765,52 +765,8 @@ void State::OnSize(m2::RectD const & /*oldPixelRect*/)
}
}
namespace
{
#ifdef DEBUG
bool ValidateTransition(State::Mode oldMode, State::Mode newMode)
{
if (oldMode == State::UnknownPosition)
return newMode == State::PendingPosition;
if (oldMode == State::PendingPosition)
{
return newMode == State::UnknownPosition ||
newMode == State::NotFollow ||
newMode == State::Follow;
}
if (oldMode == State::Follow)
{
return newMode == State::UnknownPosition ||
newMode == State::NotFollow ||
newMode == State::RotateAndFollow;
}
if (oldMode == State::NotFollow)
{
return newMode == State::Follow ||
newMode == State::RotateAndFollow;
}
if (oldMode == State::RotateAndFollow)
{
return newMode == State::NotFollow ||
newMode == State::Follow ||
newMode == State::UnknownPosition;
}
return false;
}
#endif
}
void State::AnimateStateTransition(Mode oldMode, Mode newMode)
{
ASSERT(ValidateTransition(oldMode, newMode), ("from", oldMode, "to", newMode));
StopAllAnimations();
if (oldMode == PendingPosition && newMode == Follow)