forked from organicmaps/organicmaps
New displaying of transfer titles.
This commit is contained in:
parent
3a83cf6fff
commit
6762ff3867
13 changed files with 105 additions and 29 deletions
|
@ -604,6 +604,7 @@ void ApplyPointFeature::Finish(ref_ptr<dp::TextureManager> texMng)
|
|||
textParams.m_specialPriority = specialModePriority;
|
||||
textParams.m_startOverlayRank = hasPOI ? dp::OverlayRank1 : dp::OverlayRank0;
|
||||
m_insertShape(make_unique_dp<TextShape>(m_centerPoint, textParams, m_tileKey, symbolSize,
|
||||
m2::PointF(0.0f, 0.0f) /* symbolOffset */,
|
||||
dp::Center /* symbolAnchor */, 0 /* textIndex */));
|
||||
}
|
||||
}
|
||||
|
@ -1190,6 +1191,7 @@ void ApplyLineFeatureAdditional::Finish(ref_ptr<dp::TextureManager> texMng,
|
|||
|
||||
m_insertShape(make_unique_dp<TextShape>(shieldPos, textParams, m_tileKey,
|
||||
m2::PointF(0.0f, 0.0f) /* symbolSize */,
|
||||
m2::PointF(0.0f, 0.0f) /* symbolOffset */,
|
||||
dp::Center /* symbolAnchor */, textIndex));
|
||||
if (IsColoredRoadShield(shield))
|
||||
m_insertShape(make_unique_dp<ColoredSymbolShape>(shieldPos, symbolParams, m_tileKey, textIndex));
|
||||
|
|
|
@ -249,6 +249,7 @@ void DrapeEngine::UpdateUserMarksGroup(MarkGroupID groupId, UserMarksProvider *
|
|||
renderInfo->m_symbolNames = mark->GetSymbolNames();
|
||||
renderInfo->m_coloredSymbols = mark->GetColoredSymbols();
|
||||
renderInfo->m_symbolSizes = mark->GetSymbolSizes();
|
||||
renderInfo->m_symbolOffsets = mark->GetSymbolOffsets();
|
||||
renderInfo->m_hasSymbolPriority = mark->HasSymbolPriority();
|
||||
renderInfo->m_hasTitlePriority = mark->HasTitlePriority();
|
||||
renderInfo->m_priority = mark->GetPriority();
|
||||
|
|
|
@ -555,9 +555,10 @@ void RuleDrawer::DrawTileNet(TInsertShapeFn const & insertShape)
|
|||
strings::to_string(key.m_zoomLevel);
|
||||
|
||||
tp.m_titleDecl.m_primaryTextFont = dp::FontDecl(dp::Color::Red(), 30);
|
||||
tp.m_titleDecl.m_primaryOffset = {0.f, 0.f};
|
||||
tp.m_titleDecl.m_primaryOffset = {0.0f, 0.0f};
|
||||
drape_ptr<TextShape> textShape = make_unique_dp<TextShape>(r.Center(), tp, key,
|
||||
m2::PointF(0.0, 0.0) /* symbolSize */,
|
||||
m2::PointF(0.0f, 0.0f) /* symbolSize */,
|
||||
m2::PointF(0.0f, 0.0f) /* symbolOffset */,
|
||||
dp::Anchor::Center,
|
||||
0 /* textIndex */);
|
||||
textShape->DisableDisplacing();
|
||||
|
|
|
@ -151,12 +151,13 @@ private:
|
|||
|
||||
TextShape::TextShape(m2::PointD const & basePoint, TextViewParams const & params,
|
||||
TileKey const & tileKey,
|
||||
m2::PointF const & symbolSize, dp::Anchor symbolAnchor,
|
||||
m2::PointF const & symbolSize, m2::PointF const & symbolOffset, dp::Anchor symbolAnchor,
|
||||
uint32_t textIndex)
|
||||
: m_basePoint(basePoint)
|
||||
, m_params(params)
|
||||
, m_tileCoords(tileKey.GetTileCoords())
|
||||
, m_symbolAnchor(symbolAnchor)
|
||||
, m_symbolOffset(symbolOffset)
|
||||
, m_textIndex(textIndex)
|
||||
{
|
||||
m_symbolSizes.push_back(symbolSize);
|
||||
|
@ -164,12 +165,13 @@ TextShape::TextShape(m2::PointD const & basePoint, TextViewParams const & params
|
|||
|
||||
TextShape::TextShape(m2::PointD const & basePoint, TextViewParams const & params,
|
||||
TileKey const & tileKey, std::vector<m2::PointF> const & symbolSizes,
|
||||
dp::Anchor symbolAnchor, uint32_t textIndex)
|
||||
m2::PointF const & symbolOffset, dp::Anchor symbolAnchor, uint32_t textIndex)
|
||||
: m_basePoint(basePoint)
|
||||
, m_params(params)
|
||||
, m_tileCoords(tileKey.GetTileCoords())
|
||||
, m_symbolSizes(symbolSizes)
|
||||
, m_symbolAnchor(symbolAnchor)
|
||||
, m_symbolOffset(symbolOffset)
|
||||
, m_textIndex(textIndex)
|
||||
{
|
||||
ASSERT_GREATER(m_symbolSizes.size(), 0, ());
|
||||
|
@ -260,6 +262,8 @@ void TextShape::Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManager> t
|
|||
CalculateTextOffsets(titleDecl, primaryLayout.GetPixelSize(),
|
||||
secondaryLayout != nullptr ? secondaryLayout->GetPixelSize() : m2::PointF(0.0f, 0.0f),
|
||||
primaryOffset, secondaryOffset);
|
||||
primaryOffset += glsl::vec2(m_symbolOffset.x, m_symbolOffset.y);
|
||||
secondaryOffset += glsl::vec2(m_symbolOffset.x, m_symbolOffset.y);
|
||||
|
||||
if (primaryLayout.GetGlyphCount() > 0)
|
||||
{
|
||||
|
|
|
@ -18,12 +18,12 @@ class TextShape : public MapShape
|
|||
{
|
||||
public:
|
||||
TextShape(m2::PointD const & basePoint, TextViewParams const & params,
|
||||
TileKey const & tileKey, m2::PointF const & symbolSize,
|
||||
TileKey const & tileKey, m2::PointF const & symbolSize, m2::PointF const & symbolOffset,
|
||||
dp::Anchor symbolAnchor, uint32_t textIndex);
|
||||
|
||||
TextShape(m2::PointD const & basePoint, TextViewParams const & params,
|
||||
TileKey const & tileKey, std::vector<m2::PointF> const & symbolSizes,
|
||||
dp::Anchor symbolAnchor, uint32_t textIndex);
|
||||
m2::PointF const & symbolOffset, dp::Anchor symbolAnchor, uint32_t textIndex);
|
||||
|
||||
void Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManager> textures) const override;
|
||||
MapShapeType GetType() const override { return MapShapeType::OverlayType; }
|
||||
|
@ -50,6 +50,7 @@ private:
|
|||
m2::PointI m_tileCoords;
|
||||
std::vector<m2::PointF> m_symbolSizes;
|
||||
dp::Anchor m_symbolAnchor;
|
||||
m2::PointF m_symbolOffset;
|
||||
uint32_t m_textIndex;
|
||||
|
||||
bool m_disableDisplacing = false;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "drape/batcher.hpp"
|
||||
|
||||
#include "indexer/feature_decl.hpp"
|
||||
#include "indexer/scales.hpp"
|
||||
|
||||
#include "geometry/clipping.hpp"
|
||||
#include "geometry/mercator.hpp"
|
||||
|
@ -119,7 +120,8 @@ void CacheUserMarks(TileKey const & tileKey, ref_ptr<dp::TextureManager> texture
|
|||
m2::PointD const tileCenter = tileKey.GetGlobalRect().Center();
|
||||
depthLayer = renderInfo.m_depthLayer;
|
||||
|
||||
m2::PointF symbolSize;
|
||||
m2::PointF symbolSize(0.0f, 0.0f);
|
||||
m2::PointF symbolOffset(0.0f, 0.0f);
|
||||
std::string symbolName;
|
||||
if (renderInfo.m_symbolNames != nullptr)
|
||||
{
|
||||
|
@ -178,7 +180,18 @@ void CacheUserMarks(TileKey const & tileKey, ref_ptr<dp::TextureManager> texture
|
|||
params.m_specialDisplacement = SpecialDisplacement::UserMark;
|
||||
params.m_specialPriority = renderInfo.m_priority;
|
||||
params.m_symbolName = symbolName;
|
||||
params.m_anchor = renderInfo.m_anchor;
|
||||
params.m_startOverlayRank = renderInfo.m_coloredSymbols != nullptr ? dp::OverlayRank1 : dp::OverlayRank0;
|
||||
if (renderInfo.m_symbolOffsets != nullptr)
|
||||
{
|
||||
ASSERT_GREATER(tileKey.m_zoomLevel, 0, ());
|
||||
ASSERT_LESS_OR_EQUAL(tileKey.m_zoomLevel, scales::UPPER_STYLE_SCALE, ());
|
||||
size_t offsetIndex = 0;
|
||||
if (tileKey.m_zoomLevel > 0)
|
||||
offsetIndex = static_cast<size_t>(min(tileKey.m_zoomLevel - 1, scales::UPPER_STYLE_SCALE));
|
||||
symbolOffset = renderInfo.m_symbolOffsets->at(offsetIndex);
|
||||
params.m_offset = symbolOffset;
|
||||
}
|
||||
PoiSymbolShape(renderInfo.m_pivot, params, tileKey,
|
||||
kStartUserMarkOverlayIndex + renderInfo.m_index).Draw(&batcher, textures);
|
||||
}
|
||||
|
@ -263,13 +276,14 @@ void CacheUserMarks(TileKey const & tileKey, ref_ptr<dp::TextureManager> texture
|
|||
|
||||
if (renderInfo.m_symbolSizes != nullptr)
|
||||
{
|
||||
TextShape(renderInfo.m_pivot, params, tileKey,
|
||||
*renderInfo.m_symbolSizes.get(), renderInfo.m_anchor, overlayIndex).Draw(&batcher, textures);
|
||||
TextShape(renderInfo.m_pivot, params, tileKey, *renderInfo.m_symbolSizes.get(),
|
||||
m2::PointF(0.0f, 0.0f) /* symbolOffset */, renderInfo.m_anchor,
|
||||
overlayIndex).Draw(&batcher, textures);
|
||||
}
|
||||
else
|
||||
{
|
||||
TextShape(renderInfo.m_pivot, params, tileKey,
|
||||
symbolSize, renderInfo.m_anchor, overlayIndex).Draw(&batcher, textures);
|
||||
symbolSize, symbolOffset, renderInfo.m_anchor, overlayIndex).Draw(&batcher, textures);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ struct UserMarkRenderParams
|
|||
drape_ptr<UserPointMark::SymbolNameZoomInfo> m_symbolNames;
|
||||
drape_ptr<UserPointMark::TitlesInfo> m_titleDecl;
|
||||
drape_ptr<UserPointMark::SymbolSizes> m_symbolSizes;
|
||||
drape_ptr<UserPointMark::SymbolOffsets> m_symbolOffsets;
|
||||
bool m_hasSymbolPriority = false;
|
||||
bool m_hasTitlePriority = false;
|
||||
uint16_t m_priority = 0;
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
using SymbolNameZoomInfo = std::map<int, std::string>;
|
||||
using TitlesInfo = std::vector<dp::TitleDecl>;
|
||||
using SymbolSizes = std::vector<m2::PointF>;
|
||||
using SymbolOffsets = std::vector<m2::PointF>;
|
||||
|
||||
UserPointMark();
|
||||
virtual ~UserPointMark() {}
|
||||
|
@ -62,6 +63,7 @@ public:
|
|||
virtual drape_ptr<SymbolNameZoomInfo> GetSymbolNames() const = 0;
|
||||
virtual drape_ptr<ColoredSymbolZoomInfo> GetColoredSymbols() const = 0;
|
||||
virtual drape_ptr<SymbolSizes> GetSymbolSizes() const = 0;
|
||||
virtual drape_ptr<SymbolOffsets> GetSymbolOffsets() const = 0;
|
||||
virtual uint16_t GetPriority() const = 0;
|
||||
virtual uint32_t GetIndex() const = 0;
|
||||
virtual bool HasSymbolPriority() const = 0;
|
||||
|
|
|
@ -488,6 +488,28 @@ drape_ptr<df::UserPointMark::SymbolSizes> TransitMark::GetSymbolSizes() const
|
|||
return make_unique_dp<SymbolSizes>(m_symbolSizes);
|
||||
}
|
||||
|
||||
void TransitMark::SetSymbolOffsets(SymbolOffsets const & symbolOffsets)
|
||||
{
|
||||
m_symbolOffsets = symbolOffsets;
|
||||
}
|
||||
|
||||
drape_ptr<df::UserPointMark::SymbolOffsets> TransitMark::GetSymbolOffsets() const
|
||||
{
|
||||
if (m_symbolOffsets.empty())
|
||||
return nullptr;
|
||||
return make_unique_dp<SymbolOffsets>(m_symbolOffsets);
|
||||
}
|
||||
|
||||
void TransitMark::SetAnchor(dp::Anchor anchor)
|
||||
{
|
||||
m_anchor = anchor;
|
||||
}
|
||||
|
||||
dp::Anchor TransitMark::GetAnchor() const
|
||||
{
|
||||
return m_anchor;
|
||||
}
|
||||
|
||||
drape_ptr<df::UserPointMark::SymbolNameZoomInfo> TransitMark::GetSymbolNames() const
|
||||
{
|
||||
if (m_symbolNames.empty())
|
||||
|
|
|
@ -110,13 +110,15 @@ public:
|
|||
TransitMark(m2::PointD const & ptOrg, UserMarkContainer * container);
|
||||
virtual ~TransitMark() {}
|
||||
|
||||
dp::Anchor GetAnchor() const override { return dp::Center; }
|
||||
df::RenderState::DepthLayer GetDepthLayer() const override { return df::RenderState::TransitMarkLayer; }
|
||||
UserMark::Type GetMarkType() const override { return Type::TRANSIT; }
|
||||
|
||||
bool HasSymbolPriority() const override { return !m_symbolNames.empty() || !m_coloredSymbols.empty(); }
|
||||
bool HasTitlePriority() const override { return true; }
|
||||
|
||||
void SetAnchor(dp::Anchor anchor);
|
||||
dp::Anchor GetAnchor() const override;
|
||||
|
||||
void SetFeatureId(FeatureID featureId);
|
||||
FeatureID GetFeatureID() const override { return m_featureId; }
|
||||
|
||||
|
@ -141,6 +143,9 @@ public:
|
|||
void SetSymbolSizes(SymbolSizes const & symbolSizes);
|
||||
drape_ptr<SymbolSizes> GetSymbolSizes() const override;
|
||||
|
||||
void SetSymbolOffsets(SymbolOffsets const & symbolSizes);
|
||||
drape_ptr<SymbolOffsets> GetSymbolOffsets() const override;
|
||||
|
||||
void AddTitle(dp::TitleDecl const & titleDecl);
|
||||
drape_ptr<TitlesInfo> GetTitleDecl() const override;
|
||||
|
||||
|
@ -156,4 +161,6 @@ private:
|
|||
SymbolNameZoomInfo m_symbolNames;
|
||||
ColoredSymbolZoomInfo m_coloredSymbols;
|
||||
SymbolSizes m_symbolSizes;
|
||||
SymbolOffsets m_symbolOffsets;
|
||||
dp::Anchor m_anchor = dp::Center;
|
||||
};
|
||||
|
|
|
@ -27,7 +27,7 @@ const int kLargeIconZoom = 15;
|
|||
|
||||
const int kMinStopTitleZoom = 13;
|
||||
|
||||
const int kTransferTitleOffset = 1;
|
||||
const int kTransferTitleOffset = 2;
|
||||
const int kStopTitleOffset = 0;
|
||||
const int kGateTitleOffset = 0;
|
||||
|
||||
|
@ -457,25 +457,37 @@ void TransitRouteDisplay::CollectTransitDisplayInfo(vector<RouteSegment> const &
|
|||
}
|
||||
}
|
||||
|
||||
TransitMark * TransitRouteDisplay::CreateMark(m2::PointD const & pt, FeatureID const & fid)
|
||||
{
|
||||
auto & marksController = m_bmManager->GetUserMarksController(UserMark::Type::TRANSIT);
|
||||
uint32_t const nextIndex = static_cast<uint32_t>(marksController.GetUserMarkCount());
|
||||
|
||||
auto userMark = marksController.CreateUserMark(pt);
|
||||
ASSERT(dynamic_cast<TransitMark *>(userMark) != nullptr, ());
|
||||
auto transitMark = static_cast<TransitMark *>(userMark);
|
||||
|
||||
transitMark->SetFeatureId(fid);
|
||||
transitMark->SetIndex(nextIndex);
|
||||
return transitMark;
|
||||
}
|
||||
|
||||
void TransitRouteDisplay::CreateTransitMarks(std::vector<TransitMarkInfo> const & transitMarks)
|
||||
{
|
||||
std::vector<m2::PointF> const transferMarkerSizes = GetTransitMarkerSizes(kTransferMarkerScale, m_maxSubrouteWidth);
|
||||
std::vector<m2::PointF> const stopMarkerSizes = GetTransitMarkerSizes(kStopMarkerScale, m_maxSubrouteWidth);
|
||||
|
||||
auto & marksController = m_bmManager->GetUserMarksController(UserMark::Type::TRANSIT);
|
||||
uint32_t nextIndex = static_cast<uint32_t>(marksController.GetUserMarkCount());
|
||||
std::vector<m2::PointF> transferArrowOffsets;
|
||||
for (auto const & size : transferMarkerSizes)
|
||||
transferArrowOffsets.emplace_back(0.0f, size.y * 0.5f);
|
||||
|
||||
auto const vs = static_cast<float>(df::VisualParams::Instance().GetVisualScale());
|
||||
|
||||
for (size_t i = 0; i < transitMarks.size(); ++i)
|
||||
{
|
||||
auto const & mark = transitMarks[i];
|
||||
auto transitMark = CreateMark(mark.m_point, mark.m_featureId);
|
||||
|
||||
auto userMark = marksController.CreateUserMark(mark.m_point);
|
||||
ASSERT(dynamic_cast<TransitMark *>(userMark) != nullptr, ());
|
||||
auto transitMark = static_cast<TransitMark *>(userMark);
|
||||
dp::TitleDecl titleDecl;
|
||||
|
||||
transitMark->SetFeatureId(mark.m_featureId);
|
||||
transitMark->SetIndex(nextIndex++);
|
||||
if (mark.m_type == TransitMarkInfo::Type::Gate)
|
||||
{
|
||||
if (!mark.m_titles.empty())
|
||||
|
@ -498,20 +510,27 @@ void TransitRouteDisplay::CreateTransitMarks(std::vector<TransitMarkInfo> const
|
|||
{
|
||||
if (mark.m_titles.size() > 1)
|
||||
{
|
||||
auto titleTransitMark = CreateMark(mark.m_point, mark.m_featureId);
|
||||
|
||||
TransitMark::GetDefaultTransitTitle(titleDecl);
|
||||
titleDecl.m_primaryText = mark.m_titles.front().m_text;
|
||||
titleDecl.m_primaryTextFont.m_color = df::GetColorConstant(mark.m_titles.front().m_color);
|
||||
titleDecl.m_primaryOffset.y = -kTransferTitleOffset;
|
||||
titleDecl.m_anchor = dp::Anchor::Bottom;
|
||||
titleDecl.m_primaryOptional = true;
|
||||
transitMark->AddTitle(titleDecl);
|
||||
titleDecl.m_primaryOffset.x = -kTransferTitleOffset * vs;
|
||||
titleDecl.m_anchor = dp::Anchor::Right;
|
||||
titleDecl.m_primaryOptional = false;
|
||||
titleTransitMark->AddTitle(titleDecl);
|
||||
|
||||
titleDecl.m_primaryText = mark.m_titles.back().m_text;
|
||||
titleDecl.m_primaryTextFont.m_color = df::GetColorConstant(mark.m_titles.back().m_color);
|
||||
titleDecl.m_primaryOffset.y = kTransferTitleOffset;
|
||||
titleDecl.m_anchor = dp::Anchor::Top;
|
||||
titleDecl.m_primaryOptional = true;
|
||||
transitMark->AddTitle(titleDecl);
|
||||
titleDecl.m_primaryOffset.x = kTransferTitleOffset * vs;
|
||||
titleDecl.m_anchor = dp::Anchor::Left;
|
||||
titleDecl.m_primaryOptional = false;
|
||||
titleTransitMark->AddTitle(titleDecl);
|
||||
|
||||
titleTransitMark->SetAnchor(dp::Top);
|
||||
titleTransitMark->SetSymbolNames({{1 /* minZoom */, "transfer_arrow"}});
|
||||
titleTransitMark->SetSymbolOffsets(transferArrowOffsets);
|
||||
titleTransitMark->SetPriority(UserMark::Priority::TransitTransfer);
|
||||
}
|
||||
df::UserPointMark::ColoredSymbolZoomInfo coloredSymbol;
|
||||
for (size_t sizeIndex = 0; sizeIndex < transferMarkerSizes.size(); ++sizeIndex)
|
||||
|
@ -524,7 +543,6 @@ void TransitRouteDisplay::CreateTransitMarks(std::vector<TransitMarkInfo> const
|
|||
if (coloredSymbol.empty() || coloredSymbol.rbegin()->second.m_radiusInPixels != params.m_radiusInPixels)
|
||||
coloredSymbol.insert(make_pair(zoomLevel, params));
|
||||
}
|
||||
transitMark->SetSymbolSizes(transferMarkerSizes);
|
||||
transitMark->SetColoredSymbols(coloredSymbol);
|
||||
transitMark->SetPriority(UserMark::Priority::TransitTransfer);
|
||||
}
|
||||
|
@ -588,5 +606,6 @@ void TransitRouteDisplay::CreateTransitMarks(std::vector<TransitMarkInfo> const
|
|||
}
|
||||
}
|
||||
|
||||
auto & marksController = m_bmManager->GetUserMarksController(UserMark::Type::TRANSIT);
|
||||
marksController.NotifyChanges();
|
||||
}
|
||||
|
|
|
@ -116,6 +116,7 @@ private:
|
|||
void CollectTransitDisplayInfo(std::vector<routing::RouteSegment> const & segments,
|
||||
TransitDisplayInfos & transitDisplayInfos);
|
||||
void CreateTransitMarks(std::vector<TransitMarkInfo> const & transitMarks);
|
||||
TransitMark * CreateMark(m2::PointD const & pt, FeatureID const & fid);
|
||||
|
||||
TransitReadManager & m_transitReadManager;
|
||||
GetMwmIdFn m_getMwmIdFn;
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
drape_ptr<TitlesInfo> GetTitleDecl() const override { return nullptr; }
|
||||
drape_ptr<ColoredSymbolZoomInfo> GetColoredSymbols() const override { return nullptr; }
|
||||
drape_ptr<SymbolSizes> GetSymbolSizes() const override { return nullptr; }
|
||||
drape_ptr<SymbolOffsets> GetSymbolOffsets() const override { return nullptr; }
|
||||
uint16_t GetPriority() const override { return static_cast<uint16_t >(Priority::Default); }
|
||||
uint32_t GetIndex() const override { return 0; }
|
||||
bool HasSymbolPriority() const override { return false; }
|
||||
|
|
Loading…
Add table
Reference in a new issue