Merge pull request #3217 from rokuz/improve-user-marks

Improved user marks
This commit is contained in:
Daria Volvenkova 2016-05-17 14:26:16 +04:00
commit e4443bec67
17 changed files with 110 additions and 140 deletions

View file

@ -148,7 +148,7 @@ void CacheUserPoints(UserMarksProvider const * provider,
AlignHorizontal(pxSize.x * 0.5f, anchor, left, right);
AlignVertical(pxSize.y * 0.5f, anchor, up, down);
m2::PointD const & pixelOffset = pointMark->GetPixelOffset();
m2::PointD const pixelOffset = pointMark->GetPixelOffset();
glsl::vec2 const offset(pixelOffset.x, pixelOffset.y);
buffer.emplace_back(pos, left + down + offset, glsl::ToVec2(texRect.LeftTop()), runAnim);

View file

@ -16,7 +16,7 @@ class UserPointMark
public:
virtual ~UserPointMark() {}
virtual m2::PointD const & GetPivot() const = 0;
virtual m2::PointD const & GetPixelOffset() const = 0;
virtual m2::PointD GetPixelOffset() const = 0;
virtual string GetSymbolName() const = 0;
virtual dp::Anchor GetAnchor() const = 0;
virtual float GetDepth() const = 0;

View file

@ -1,15 +0,0 @@
#include "map/api_mark_container.hpp"
#include "map/api_mark_point.hpp"
#include "map/framework.hpp"
ApiUserMarkContainer::ApiUserMarkContainer(double layerDepth, Framework & framework)
: UserMarkContainer(layerDepth, UserMarkType::API_MARK, framework)
{
}
UserMark * ApiUserMarkContainer::AllocateUserMark(const m2::PointD & ptOrg)
{
return new ApiMarkPoint(ptOrg, this);
}

View file

@ -1,12 +0,0 @@
#pragma once
#include "map/user_mark_container.hpp"
class ApiUserMarkContainer : public UserMarkContainer
{
public:
ApiUserMarkContainer(double layerDepth, Framework & framework);
protected:
UserMark * AllocateUserMark(m2::PointD const & ptOrg) override;
};

View file

@ -1,29 +1,13 @@
#include "map/styled_point.hpp"
#include "map/api_mark_point.hpp"
#include "base/logging.hpp"
namespace
{
char const * kSupportedColors[] = {"placemark-red", "placemark-blue", "placemark-purple",
"placemark-yellow", "placemark-pink", "placemark-brown",
"placemark-green", "placemark-orange"};
}
namespace style
{
StyledPoint::StyledPoint(m2::PointD const & ptOrg, UserMarkContainer * container)
: UserMark(ptOrg, container)
{
}
m2::PointD const & StyledPoint::GetPixelOffset() const
{
static m2::PointD const s_centre(0.0, 0.0);
static m2::PointD const s_offset(0.0, 3.0);
return GetStyle().empty() ? s_centre : s_offset;
}
char const * kSupportedColors[] = {"placemark-red", "placemark-blue", "placemark-purple",
"placemark-yellow", "placemark-pink", "placemark-brown",
"placemark-green", "placemark-orange"};
string GetSupportedStyle(string const & s, string const & context, string const & fallback)
{
@ -42,4 +26,32 @@ string GetSupportedStyle(string const & s, string const & context, string const
}
string GetDefaultStyle() { return kSupportedColors[0]; }
} // namespace style
} // style
ApiMarkPoint::ApiMarkPoint(m2::PointD const & ptOrg, UserMarkContainer * container)
: UserMark(ptOrg, container)
{}
ApiMarkPoint::ApiMarkPoint(string const & name, string const & id, string const & style,
m2::PointD const & ptOrg, UserMarkContainer * container)
: UserMark(ptOrg, container),
m_name(name),
m_id(id),
m_style(style)
{}
string ApiMarkPoint::GetSymbolName() const
{
return m_style.empty() ? "api-result" : m_style;
}
UserMark::Type ApiMarkPoint::GetMarkType() const
{
return UserMark::Type::API;
}
m2::PointD ApiMarkPoint::GetPixelOffset() const
{
return m_style.empty() ? m2::PointD(0.0, 0.0) : m2::PointD(0.0, 3.0);
}

View file

@ -1,37 +1,42 @@
#pragma once
#include "map/styled_point.hpp"
#include "map/user_mark.hpp"
#include "map/user_mark_container.hpp"
class ApiMarkPoint : public style::StyledPoint
#include "geometry/point2d.hpp"
#include "std/string.hpp"
namespace style
{
// Fixes icons which are not supported by MapsWithMe.
string GetSupportedStyle(string const & s, string const & context, string const & fallback);
// Default icon.
string GetDefaultStyle();
} // style
class ApiMarkPoint : public UserMark
{
public:
ApiMarkPoint(m2::PointD const & ptOrg, UserMarkContainer * container)
: StyledPoint(ptOrg, container)
{
}
ApiMarkPoint(m2::PointD const & ptOrg, UserMarkContainer * container);
ApiMarkPoint(string const & name, string const & id, string const & style,
m2::PointD const & ptOrg, UserMarkContainer * container)
: StyledPoint(ptOrg, container), m_name(name), m_id(id), m_style(style)
{
}
m2::PointD const & ptOrg, UserMarkContainer * container);
string GetSymbolName() const override { return "api-result"; }
UserMark::Type GetMarkType() const override { return UserMark::Type::API; }
string GetSymbolName() const override;
UserMark::Type GetMarkType() const override;
m2::PointD GetPixelOffset() const override;
string const & GetName() const { return m_name; }
void SetName(string const & name) { m_name = name; }
string const & GetID() const { return m_id; }
void SetID(string const & id) { m_id = id; }
void SetStyle(string const & style) { m_style = style; }
// StyledPoint overrides:
string const & GetStyle() const override { return m_style; }
string const & GetStyle() const { return m_style; }
private:
string m_name;

View file

@ -2,7 +2,6 @@
#include "map/user_mark.hpp"
#include "map/user_mark_container.hpp"
#include "map/styled_point.hpp"
#include "coding/reader.hpp"

View file

@ -1,4 +1,3 @@
#include "map/api_mark_container.hpp"
#include "map/bookmark_manager.hpp"
#include "map/framework.hpp"
#include "map/user_mark.hpp"

View file

@ -736,10 +736,10 @@ void Framework::FillApiMarkInfo(ApiMarkPoint const & api, place_page::Info & inf
void Framework::FillSearchResultInfo(SearchMarkPoint const & smp, place_page::Info & info) const
{
if (smp.m_foundFeatureID.IsValid())
FillFeatureInfo(smp.m_foundFeatureID, info);
if (smp.GetFoundFeature().IsValid())
FillFeatureInfo(smp.GetFoundFeature(), info);
else
FillPointInfo(smp.GetPivot(), smp.m_matchedName, info);
FillPointInfo(smp.GetPivot(), smp.GetMatchedName(), info);
}
void Framework::FillMyPositionInfo(place_page::Info & info) const
@ -1416,8 +1416,11 @@ void Framework::FillSearchResultsMarks(search::Results const & results)
SearchMarkPoint * mark = static_cast<SearchMarkPoint *>(guard.m_controller.CreateUserMark(r.GetFeatureCenter()));
ASSERT_EQUAL(mark->GetMarkType(), UserMark::Type::SEARCH, ());
if (r.GetResultType() == search::Result::RESULT_FEATURE)
mark->m_foundFeatureID = r.GetFeatureID();
mark->m_matchedName = r.GetString();
mark->SetFoundFeature(r.GetFeatureID());
mark->SetMatchedName(r.GetString());
//TODO: extract from search::Result data for choosing custom symbol.
//mark->SetCustomSymbol("booking-search-result");
}
}
}

View file

@ -11,7 +11,6 @@ INCLUDEPATH *= $$ROOT_DIR/3party/protobuf/src $$ROOT_DIR/3party/freetype/include
include($$ROOT_DIR/common.pri)
HEADERS += \
api_mark_container.hpp \
api_mark_point.hpp \
bookmark.hpp \
bookmark_manager.hpp \
@ -26,7 +25,6 @@ HEADERS += \
gps_tracker.hpp \
mwm_url.hpp \
place_page_info.hpp \
styled_point.hpp \
track.hpp \
user_mark.hpp \
user_mark_container.hpp \
@ -34,7 +32,7 @@ HEADERS += \
SOURCES += \
../api/src/c/api-client.c \
address_finder.cpp \
api_mark_container.cpp \
api_mark_point.cpp \
bookmark.cpp \
bookmark_manager.cpp \
feature_vec_model.cpp \
@ -48,7 +46,6 @@ SOURCES += \
gps_tracker.cpp \
mwm_url.cpp \
place_page_info.cpp \
styled_point.cpp \
track.cpp \
user_mark.cpp \
user_mark_container.cpp \

View file

@ -2,6 +2,8 @@
#include "map/bookmark.hpp"
#include "storage/index.hpp"
#include "indexer/feature_data.hpp"
#include "indexer/feature_meta.hpp"
#include "indexer/map_object.hpp"

View file

@ -1,33 +0,0 @@
#pragma once
#include "map/user_mark.hpp"
#include "map/user_mark_container.hpp"
#include "search/result.hpp"
#include "indexer/feature.hpp"
#include "geometry/point2d.hpp"
#include "std/string.hpp"
#include "std/unique_ptr.hpp"
#include "std/utility.hpp"
namespace style
{
// Fixes icons which are not supported by MapsWithMe.
string GetSupportedStyle(string const & s, string const & context, string const & fallback);
// Default icon.
string GetDefaultStyle();
class StyledPoint : public UserMark
{
public:
StyledPoint(m2::PointD const & ptOrg, UserMarkContainer * container);
m2::PointD const & GetPixelOffset() const override;
/// @return name of icon, or empty string for plain circle.
virtual string const & GetStyle() const = 0;
};
} // namespace style

View file

@ -17,10 +17,9 @@ m2::PointD const & UserMark::GetPivot() const
return m_ptOrg;
}
m2::PointD const & UserMark::GetPixelOffset() const
m2::PointD UserMark::GetPixelOffset() const
{
static m2::PointD const s_centre(0.0, 0.0);
return s_centre;
return m2::PointD(0.0, 0.0);
}
dp::Anchor UserMark::GetAnchor() const
@ -56,7 +55,7 @@ SearchMarkPoint::SearchMarkPoint(m2::PointD const & ptOrg, UserMarkContainer * c
string SearchMarkPoint::GetSymbolName() const
{
return "search-result";
return m_customSymbol.empty() ? "search-result" : m_customSymbol;
}
UserMark::Type SearchMarkPoint::GetMarkType() const

View file

@ -34,20 +34,16 @@ public:
UserMark(m2::PointD const & ptOrg, UserMarkContainer * container);
virtual ~UserMark() {}
///////////////////////////////////////////////////////
/// df::UserPointMark
// df::UserPointMark overrides.
m2::PointD const & GetPivot() const override;
m2::PointD const & GetPixelOffset() const override;
m2::PointD GetPixelOffset() const override;
dp::Anchor GetAnchor() const override;
float GetDepth() const override;
bool RunCreationAnim() const override;
///////////////////////////////////////////////////////
UserMarkContainer const * GetContainer() const;
ms::LatLon GetLatLon() const;
virtual Type GetMarkType() const = 0;
// Need it to calculate POI rank from all taps to features via statistics.
using TEventContainer = map<string, string>;
protected:
m2::PointD m_ptOrg;
@ -61,11 +57,21 @@ public:
string GetSymbolName() const override;
UserMark::Type GetMarkType() const override;
// TODO: Do not use usermarks to store any significant information for UI/core.
// Refactor them out to only display some layers on a map.
FeatureID const & GetFoundFeature() const { return m_foundFeatureID; }
void SetFoundFeature(FeatureID const & feature) { m_foundFeatureID = feature; }
string const & GetMatchedName() const { return m_matchedName; }
void SetMatchedName(string const & name) { m_matchedName = name; }
string const & GetCustomSymbol() const { return m_customSymbol; }
void SetCustomSymbol(string const & symbol) { m_customSymbol = symbol; }
protected:
FeatureID m_foundFeatureID;
// Used to pass exact search result matched string into a place page.
string m_matchedName;
string m_customSymbol;
};
class PoiMarkPoint : public SearchMarkPoint

View file

@ -286,3 +286,14 @@ UserMark * DebugUserMarkContainer::AllocateUserMark(const m2::PointD & ptOrg)
{
return new DebugMarkPoint(ptOrg, this);
}
ApiUserMarkContainer::ApiUserMarkContainer(double layerDepth, Framework & framework)
: UserMarkContainer(layerDepth, UserMarkType::API_MARK, framework)
{
}
UserMark * ApiUserMarkContainer::AllocateUserMark(const m2::PointD & ptOrg)
{
return new ApiMarkPoint(ptOrg, this);
}

View file

@ -116,3 +116,12 @@ public:
protected:
UserMark * AllocateUserMark(m2::PointD const & ptOrg) override;
};
class ApiUserMarkContainer : public UserMarkContainer
{
public:
ApiUserMarkContainer(double layerDepth, Framework & framework);
protected:
UserMark * AllocateUserMark(m2::PointD const & ptOrg) override;
};

View file

@ -9,11 +9,8 @@
/* Begin PBXBuildFile section */
34583BCF1C88556800F94664 /* place_page_info.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 34583BCD1C88556800F94664 /* place_page_info.cpp */; };
34583BD01C88556800F94664 /* place_page_info.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 34583BCE1C88556800F94664 /* place_page_info.hpp */; };
34921F641BFA0A6900737D6E /* api_mark_container.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 34921F5F1BFA0A6900737D6E /* api_mark_container.cpp */; };
34921F651BFA0A6900737D6E /* api_mark_container.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 34921F601BFA0A6900737D6E /* api_mark_container.hpp */; };
34921F661BFA0A6900737D6E /* api_mark_point.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 34921F611BFA0A6900737D6E /* api_mark_point.hpp */; };
34921F671BFA0A6900737D6E /* styled_point.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 34921F621BFA0A6900737D6E /* styled_point.cpp */; };
34921F681BFA0A6900737D6E /* styled_point.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 34921F631BFA0A6900737D6E /* styled_point.hpp */; };
45201E931CE4AC90008A4842 /* api_mark_point.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 45201E921CE4AC90008A4842 /* api_mark_point.cpp */; };
670E39401C46C5C700E9C0A6 /* gps_tracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 670E393E1C46C5C700E9C0A6 /* gps_tracker.cpp */; };
670E39411C46C5C700E9C0A6 /* gps_tracker.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 670E393F1C46C5C700E9C0A6 /* gps_tracker.hpp */; };
674A29F01B26FD6F001A525C /* testingmain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 674A29EE1B26FD5F001A525C /* testingmain.cpp */; };
@ -101,11 +98,8 @@
/* Begin PBXFileReference section */
34583BCD1C88556800F94664 /* place_page_info.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = place_page_info.cpp; sourceTree = "<group>"; };
34583BCE1C88556800F94664 /* place_page_info.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = place_page_info.hpp; sourceTree = "<group>"; };
34921F5F1BFA0A6900737D6E /* api_mark_container.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = api_mark_container.cpp; sourceTree = "<group>"; };
34921F601BFA0A6900737D6E /* api_mark_container.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = api_mark_container.hpp; sourceTree = "<group>"; };
34921F611BFA0A6900737D6E /* api_mark_point.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = api_mark_point.hpp; sourceTree = "<group>"; };
34921F621BFA0A6900737D6E /* styled_point.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = styled_point.cpp; sourceTree = "<group>"; };
34921F631BFA0A6900737D6E /* styled_point.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = styled_point.hpp; sourceTree = "<group>"; };
45201E921CE4AC90008A4842 /* api_mark_point.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = api_mark_point.cpp; sourceTree = "<group>"; };
670D05A41B0DF4250013A7AC /* defaults.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = defaults.xcconfig; path = ../defaults.xcconfig; sourceTree = "<group>"; };
670E393E1C46C5C700E9C0A6 /* gps_tracker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gps_tracker.cpp; sourceTree = "<group>"; };
670E393F1C46C5C700E9C0A6 /* gps_tracker.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = gps_tracker.hpp; sourceTree = "<group>"; };
@ -327,11 +321,8 @@
F6B283011C1B03320081957A /* gps_track.cpp */,
F6B283021C1B03320081957A /* gps_track.hpp */,
674C385F1BFF3095000D603B /* user_mark.cpp */,
34921F5F1BFA0A6900737D6E /* api_mark_container.cpp */,
34921F601BFA0A6900737D6E /* api_mark_container.hpp */,
34921F611BFA0A6900737D6E /* api_mark_point.hpp */,
34921F621BFA0A6900737D6E /* styled_point.cpp */,
34921F631BFA0A6900737D6E /* styled_point.hpp */,
45201E921CE4AC90008A4842 /* api_mark_point.cpp */,
675345CB1A4054E800A0A8C3 /* address_finder.cpp */,
675345D91A4054E800A0A8C3 /* bookmark_manager.cpp */,
675345DA1A4054E800A0A8C3 /* bookmark_manager.hpp */,
@ -374,9 +365,7 @@
34921F661BFA0A6900737D6E /* api_mark_point.hpp in Headers */,
675346751A4054E800A0A8C3 /* mwm_url.hpp in Headers */,
6753464B1A4054E800A0A8C3 /* bookmark.hpp in Headers */,
34921F681BFA0A6900737D6E /* styled_point.hpp in Headers */,
6753469E1A4054E800A0A8C3 /* user_mark_container.hpp in Headers */,
34921F651BFA0A6900737D6E /* api_mark_container.hpp in Headers */,
675346491A4054E800A0A8C3 /* bookmark_manager.hpp in Headers */,
F6B2830A1C1B03320081957A /* gps_track.hpp in Headers */,
675346631A4054E800A0A8C3 /* feature_vec_model.hpp in Headers */,
@ -488,16 +477,15 @@
6753469B1A4054E800A0A8C3 /* track.cpp in Sources */,
675346621A4054E800A0A8C3 /* feature_vec_model.cpp in Sources */,
6753469D1A4054E800A0A8C3 /* user_mark_container.cpp in Sources */,
34921F641BFA0A6900737D6E /* api_mark_container.cpp in Sources */,
674C38621BFF3095000D603B /* user_mark.cpp in Sources */,
675346641A4054E800A0A8C3 /* framework.cpp in Sources */,
6753466A1A4054E800A0A8C3 /* geourl_process.cpp in Sources */,
45201E931CE4AC90008A4842 /* api_mark_point.cpp in Sources */,
675346661A4054E800A0A8C3 /* ge0_parser.cpp in Sources */,
F6B283071C1B03320081957A /* gps_track_storage.cpp in Sources */,
6753463A1A4054E800A0A8C3 /* address_finder.cpp in Sources */,
670E39401C46C5C700E9C0A6 /* gps_tracker.cpp in Sources */,
6753464A1A4054E800A0A8C3 /* bookmark.cpp in Sources */,
34921F671BFA0A6900737D6E /* styled_point.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};