Merge pull request #4084 from rokuz/search-marks-size

Added retrieving size of search marks in mercator
This commit is contained in:
ygorshenin 2016-08-18 13:34:39 +03:00 committed by GitHub
commit becf0013f6
8 changed files with 93 additions and 1 deletions

View file

@ -272,6 +272,22 @@ void BackendRenderer::AcceptMessage(ref_ptr<Message> message)
{
ref_ptr<Allow3dBuildingsMessage> msg = message;
m_readManager->Allow3dBuildings(msg->Allow3dBuildings());
break;
}
case Message::RequestSymbolsSize:
{
ref_ptr<RequestSymbolsSizeMessage> msg = message;
auto const & symbols = msg->GetSymbols();
vector<m2::PointU> sizes(symbols.size());
for (size_t i = 0; i < symbols.size(); i++)
{
dp::TextureManager::SymbolRegion region;
m_texMng->GetSymbolRegion(symbols[i], region);
sizes[i] = region.GetPixelSize();
}
msg->InvokeCallback(sizes);
break;
}
default:

View file

@ -473,4 +473,12 @@ void DrapeEngine::SetDisplacementMode(int mode)
MessagePriority::Normal);
}
void DrapeEngine::RequestSymbolsSize(vector<string> const & symbols,
TRequestSymbolsSizeCallback const & callback)
{
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
make_unique_dp<RequestSymbolsSizeMessage>(symbols, callback),
MessagePriority::Normal);
}
} // namespace df

View file

@ -148,6 +148,11 @@ public:
void SetDisplacementMode(int mode);
using TRequestSymbolsSizeCallback = function<void(vector<m2::PointU> const &)>;
void RequestSymbolsSize(vector<string> const & symbols,
TRequestSymbolsSizeCallback const & callback);
private:
void AddUserEvent(UserEvent const & e);
void ModelViewChanged(ScreenBase const & screen);

View file

@ -57,7 +57,8 @@ public:
SetTimeInBackground,
SetAddNewPlaceMode,
SetDisplacementMode,
AllowAutoZoom
AllowAutoZoom,
RequestSymbolsSize
};
virtual ~Message() {}

View file

@ -818,4 +818,30 @@ private:
int m_mode;
};
class RequestSymbolsSizeMessage : public Message
{
public:
using TRequestSymbolsSizeCallback = function<void(vector<m2::PointU> const &)>;
RequestSymbolsSizeMessage(vector<string> const & symbols,
TRequestSymbolsSizeCallback const & callback)
: m_symbols(symbols)
, m_callback(callback)
{}
Type GetType() const override { return Message::RequestSymbolsSize; }
vector<string> const & GetSymbols() const { return m_symbols; }
void InvokeCallback(vector<m2::PointU> const & sizes)
{
if (m_callback != nullptr)
m_callback(sizes);
}
private:
vector<string> m_symbols;
TRequestSymbolsSizeCallback m_callback;
};
} // namespace df

View file

@ -114,6 +114,13 @@ char const kAllowAutoZoom[] = "AutoZoom";
double const kDistEqualQuery = 100.0;
// Must correspond SearchMarkType.
vector<string> kSearchMarks =
{
"search-result",
"search-booking"
};
// TODO!
// To adjust GpsTrackFilter was added secret command "?gpstrackaccuracy:xxx;"
// where xxx is a new value for horizontal accuracy.
@ -1633,6 +1640,11 @@ void Framework::CreateDrapeEngine(ref_ptr<dp::OGLContextFactory> contextFactory,
place_page::Info info;
ActivateMapSelection(false, OnTapEventImpl(*m_lastTapEvent, info), info);
}
m_drapeEngine->RequestSymbolsSize(kSearchMarks, [this](vector<m2::PointU> const & sizes)
{
GetPlatform().RunOnGuiThread([this, sizes](){ m_searchMarksSizes = sizes; });
});
}
ref_ptr<df::DrapeEngine> Framework::GetDrapeEngine()
@ -2588,6 +2600,18 @@ void Framework::BlockTapEvents(bool block)
CallDrapeFunction(bind(&df::DrapeEngine::BlockTapEvents, _1, block));
}
m2::PointD Framework::GetSearchMarkSize(SearchMarkType searchMarkType)
{
if (m_searchMarksSizes.empty())
return m2::PointD();
ASSERT_LESS(static_cast<size_t>(searchMarkType), m_searchMarksSizes.size(), ());
m2::PointU const pixelSize = m_searchMarksSizes[searchMarkType];
double const pixelToMercator = m_currentModelView.GetScale();
return m2::PointD(pixelToMercator * pixelSize.x, pixelToMercator * pixelSize.y);
}
namespace feature
{
string GetPrintableTypes(FeatureType const & ft)

View file

@ -276,6 +276,8 @@ public:
BookmarkAndCategory FindBookmark(UserMark const * mark) const;
BookmarkManager & GetBookmarkManager() { return m_bmManager; }
m2::PointD GetSearchMarkSize(SearchMarkType searchMarkType);
protected:
// search::ViewportSearchCallback::Delegate overrides:
void RunUITask(function<void()> fn) override { GetPlatform().RunOnGuiThread(move(fn)); }
@ -349,6 +351,8 @@ private:
/// Here we store last selected feature to get its polygons in case of adding organization.
mutable FeatureID m_selectedFeature;
vector<m2::PointU> m_searchMarksSizes;
private:
vector<m2::TriangleD> GetSelectedFeatureTriangles() const;

View file

@ -50,6 +50,14 @@ protected:
mutable UserMarkContainer * m_container;
};
enum SearchMarkType
{
DefaultSearchMark = 0,
BookingSearchMark,
SearchMarkTypesCount
};
class SearchMarkPoint : public UserMark
{
public: