Small refactoring of API-mark

This commit is contained in:
r.kuznetsov 2016-05-12 15:34:40 +03:00
parent 07e00fcfb8
commit 7d7e58b6df
12 changed files with 86 additions and 121 deletions

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,35 @@ 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 const & ApiMarkPoint::GetPixelOffset() const
{
static m2::PointD const s_centre(0.0, 0.0);
static m2::PointD const s_offset(0.0, 3.0);
return m_style.empty() ? s_centre : s_offset;
}

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 const & 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

@ -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

@ -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;
};