forked from organicmaps/organicmaps
[drape] render bookmarks, search and api points
This commit is contained in:
parent
7230f95a75
commit
2bffbb1756
20 changed files with 613 additions and 895 deletions
|
@ -92,7 +92,10 @@
|
|||
[[Statistics instance] logEvent:kStatEventName(kStatBookmarks, kStatToggleVisibility)
|
||||
withParameters:@{kStatValue : visible ? kStatVisible : kStatHidden}];
|
||||
cell.imageView.image = [UIImage imageNamed:(visible ? @"ic_show_light" : @"ic_hide_light")];
|
||||
cat->SetVisible(visible);
|
||||
{
|
||||
BookmarkCategory::Guard guard(*cat);
|
||||
guard.m_controller.SetIsVisible(visible);
|
||||
}
|
||||
cat->SaveToKMLFile();
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +122,7 @@
|
|||
NSString * title = @(cat->GetName().c_str());
|
||||
cell.textLabel.text = [self truncateString:title toWidth:(self.tableView.width - 122) withFont:cell.textLabel.font];
|
||||
cell.imageView.image = [UIImage imageNamed:(cat->IsVisible() ? @"ic_show_light" : @"ic_hide_light")];
|
||||
cell.detailTextLabel.text = [NSString stringWithFormat:@"%ld", cat->GetBookmarksCount() + cat->GetTracksCount()];
|
||||
cell.detailTextLabel.text = [NSString stringWithFormat:@"%ld", cat->GetUserMarkCount() + cat->GetTracksCount()];
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ extern NSString * const kBookmarksChangedNotification = @"BookmarksChangedNotifi
|
|||
else if (section == m_trackSection)
|
||||
return GetFramework().GetBmCategory(m_categoryIndex)->GetTracksCount();
|
||||
else if (section == m_bookmarkSection)
|
||||
return GetFramework().GetBmCategory(m_categoryIndex)->GetBookmarksCount();
|
||||
return GetFramework().GetBmCategory(m_categoryIndex)->GetUserMarkCount();
|
||||
else if (section == m_shareSection)
|
||||
return 1;
|
||||
else
|
||||
|
@ -79,7 +79,10 @@ extern NSString * const kBookmarksChangedNotification = @"BookmarksChangedNotifi
|
|||
[[Statistics instance] logEvent:kStatEventName(kStatBookmarks, kStatToggleVisibility)
|
||||
withParameters:@{kStatValue : sender.on ? kStatVisible : kStatHidden}];
|
||||
BookmarkCategory * cat = GetFramework().GetBmCategory(m_categoryIndex);
|
||||
cat->SetVisible(sender.on);
|
||||
{
|
||||
BookmarkCategory::Guard guard(*cat);
|
||||
guard.m_controller.SetIsVisible(sender.on);
|
||||
}
|
||||
cat->SaveToKMLFile();
|
||||
}
|
||||
|
||||
|
@ -176,7 +179,7 @@ extern NSString * const kBookmarksChangedNotification = @"BookmarksChangedNotifi
|
|||
BookmarkCell * bmCell = (BookmarkCell *)[tableView dequeueReusableCellWithIdentifier:@"BookmarksVCBookmarkItemCell"];
|
||||
if (!bmCell)
|
||||
bmCell = [[BookmarkCell alloc] initWithReuseIdentifier:@"BookmarksVCBookmarkItemCell"];
|
||||
Bookmark const * bm = cat->GetBookmark(indexPath.row);
|
||||
Bookmark const * bm = static_cast<Bookmark const *>(cat->GetUserMark(indexPath.row));
|
||||
if (bm)
|
||||
{
|
||||
bmCell.bmName.text = @(bm->GetName().c_str());
|
||||
|
@ -252,7 +255,7 @@ extern NSString * const kBookmarksChangedNotification = @"BookmarksChangedNotifi
|
|||
{
|
||||
if (cat)
|
||||
{
|
||||
Bookmark const * bm = cat->GetBookmark(indexPath.row);
|
||||
Bookmark const * bm = static_cast<Bookmark const *>(cat->GetUserMark(indexPath.row));
|
||||
ASSERT(bm, ("NULL bookmark"));
|
||||
if (bm)
|
||||
{
|
||||
|
@ -335,7 +338,7 @@ extern NSString * const kBookmarksChangedNotification = @"BookmarksChangedNotifi
|
|||
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
|
||||
else
|
||||
[self.tableView reloadData];
|
||||
if (cat->GetBookmarksCount() + cat->GetTracksCount() == 0)
|
||||
if (cat->GetUserMarkCount() + cat->GetTracksCount() == 0)
|
||||
{
|
||||
self.navigationItem.rightBarButtonItem = nil;
|
||||
[self setEditing:NO animated:YES];
|
||||
|
@ -360,7 +363,7 @@ extern NSString * const kBookmarksChangedNotification = @"BookmarksChangedNotifi
|
|||
NSIndexPath * indexPath = [table indexPathForCell:cell];
|
||||
if (indexPath.section == m_bookmarkSection)
|
||||
{
|
||||
Bookmark const * bm = cat->GetBookmark(indexPath.row);
|
||||
Bookmark const * bm = static_cast<Bookmark const *>(cat->GetUserMark(indexPath.row));
|
||||
if (bm)
|
||||
{
|
||||
m2::PointD const center = bm->GetOrg();
|
||||
|
@ -389,7 +392,7 @@ extern NSString * const kBookmarksChangedNotification = @"BookmarksChangedNotifi
|
|||
|
||||
// Display Edit button only if table is not empty
|
||||
BookmarkCategory * cat = GetFramework().GetBmCategory(m_categoryIndex);
|
||||
if (cat && (cat->GetBookmarksCount() + cat->GetTracksCount()))
|
||||
if (cat && (cat->GetUserMarkCount() + cat->GetTracksCount()))
|
||||
self.navigationItem.rightBarButtonItem = self.editButtonItem;
|
||||
else
|
||||
self.navigationItem.rightBarButtonItem = nil;
|
||||
|
@ -451,7 +454,7 @@ extern NSString * const kBookmarksChangedNotification = @"BookmarksChangedNotifi
|
|||
m_trackSection = index++;
|
||||
else
|
||||
m_trackSection = EMPTY_SECTION;
|
||||
if (cat->GetBookmarksCount())
|
||||
if (cat->GetUserMarkCount())
|
||||
m_bookmarkSection = index++;
|
||||
else
|
||||
m_bookmarkSection = EMPTY_SECTION;
|
||||
|
|
216
map/bookmark.cpp
216
map/bookmark.cpp
|
@ -35,12 +35,6 @@ unique_ptr<UserMarkCopy> Bookmark::Copy() const
|
|||
return unique_ptr<UserMarkCopy>(new UserMarkCopy(this, false));
|
||||
}
|
||||
|
||||
///@TODO UVR
|
||||
//graphics::DisplayList * Bookmark::GetDisplayList(UserMarkDLCache * cache) const
|
||||
//{
|
||||
// return cache->FindUserMark(UserMarkDLCache::Key(GetType(), dp::Bottom, GetContainer()->GetDepth()));
|
||||
//}
|
||||
|
||||
double Bookmark::GetAnimScaleFactor() const
|
||||
{
|
||||
return m_animScaleFactor;
|
||||
|
@ -75,40 +69,91 @@ Track const * BookmarkCategory::GetTrack(size_t index) const
|
|||
return (index < m_tracks.size() ? m_tracks[index] : 0);
|
||||
}
|
||||
|
||||
Bookmark * BookmarkCategory::AddBookmark(m2::PointD const & ptOrg, BookmarkData const & bm)
|
||||
{
|
||||
Bookmark * bookmark = static_cast<Bookmark *>(base_t::GetController().CreateUserMark(ptOrg));
|
||||
bookmark->SetData(bm);
|
||||
return bookmark;
|
||||
}
|
||||
//void BookmarkCategory::AddBookmark(m2::PointD const & ptOrg, BookmarkData const & bm)
|
||||
//{
|
||||
// UserMark * mark = base_t::GetController().CreateUserMark(ptOrg);
|
||||
// static_cast<Bookmark *>(mark)->SetData(bm);
|
||||
//}
|
||||
|
||||
void BookmarkCategory::ReplaceBookmark(size_t index, BookmarkData const & bm)
|
||||
{
|
||||
Controller & c = base_t::GetController();
|
||||
ASSERT_LESS (index, c.GetUserMarkCount(), ());
|
||||
if (index < c.GetUserMarkCount())
|
||||
{
|
||||
Bookmark * mark = static_cast<Bookmark *>(c.GetUserMarkForEdit(index));
|
||||
mark->SetData(bm);
|
||||
}
|
||||
}
|
||||
//void BookmarkCategory::ReplaceBookmark(size_t index, BookmarkData const & bm)
|
||||
//{
|
||||
// Controller & c = base_t::GetController();
|
||||
// ASSERT_LESS (index, c.GetUserMarkCount(), ());
|
||||
// if (index < c.GetUserMarkCount())
|
||||
// {
|
||||
// Bookmark * mark = static_cast<Bookmark *>(c.GetUserMarkForEdit(index));
|
||||
// mark->SetData(bm);
|
||||
// }
|
||||
//}
|
||||
|
||||
BookmarkCategory::BookmarkCategory(const string & name, Framework & framework)
|
||||
: base_t(0.0/*graphics::bookmarkDepth*/, framework)
|
||||
//void BookmarkCategory::DeleteBookmark(size_t index)
|
||||
//{
|
||||
// base_t::Controller & c = base_t::GetController();
|
||||
// ASSERT_LESS(index, c.GetUserMarkCount(), ());
|
||||
// UserMark const * markForDelete = c.GetUserMark(index);
|
||||
|
||||
// int animIndex = -1;
|
||||
// for (size_t i = 0; i < m_anims.size(); ++i)
|
||||
// {
|
||||
// anim_node_t const & anim = m_anims[i];
|
||||
// if (anim.first == markForDelete)
|
||||
// {
|
||||
// anim.second->Cancel();
|
||||
// animIndex = i;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (animIndex != -1)
|
||||
// m_anims.erase(m_anims.begin() + animIndex);
|
||||
|
||||
// c.DeleteUserMark(index);
|
||||
//}
|
||||
|
||||
//size_t BookmarkCategory::GetBookmarksCount() const
|
||||
//{
|
||||
// return base_t::GetController().GetUserMarkCount();
|
||||
//}
|
||||
|
||||
//Bookmark const * BookmarkCategory::GetBookmark(size_t index) const
|
||||
//{
|
||||
// base_t::Controller const & c = base_t::GetController();
|
||||
// return static_cast<Bookmark const *>(index < c.GetUserMarkCount() ? c.GetUserMark(index) : 0);
|
||||
//}
|
||||
|
||||
//Bookmark * BookmarkCategory::GetBookmark(size_t index)
|
||||
//{
|
||||
// base_t::Controller & c = base_t::GetController();
|
||||
// return static_cast<Bookmark *>(index < c.GetUserMarkCount() ? c.GetUserMarkForEdit(index) : 0);
|
||||
//}
|
||||
|
||||
BookmarkCategory::BookmarkCategory(string const & name, Framework & framework)
|
||||
: TBase(0.0/*graphics::bookmarkDepth*/, UserMarkType::BOOKMARK_MARK, framework)
|
||||
, m_name(name)
|
||||
, m_blockAnimation(false)
|
||||
{
|
||||
}
|
||||
|
||||
BookmarkCategory::~BookmarkCategory()
|
||||
{
|
||||
ClearBookmarks();
|
||||
ClearTracks();
|
||||
}
|
||||
|
||||
string const & BookmarkCategory::GetSymbolName(size_t index) const
|
||||
{
|
||||
Bookmark const * bm = static_cast<Bookmark const *>(GetUserMark(index));
|
||||
return bm->GetData().GetType();
|
||||
}
|
||||
|
||||
dp::Anchor BookmarkCategory::GetAnchor(size_t index) const
|
||||
{
|
||||
UNUSED_VALUE(index);
|
||||
return dp::Bottom;
|
||||
}
|
||||
|
||||
void BookmarkCategory::ClearBookmarks()
|
||||
{
|
||||
base_t::Clear();
|
||||
RequestController().Clear();
|
||||
ReleaseController();
|
||||
}
|
||||
|
||||
void BookmarkCategory::ClearTracks()
|
||||
|
@ -135,56 +180,11 @@ template <class T> void DeleteItem(vector<T> & v, size_t i)
|
|||
|
||||
}
|
||||
|
||||
void BookmarkCategory::DeleteBookmark(size_t index)
|
||||
{
|
||||
base_t::Controller & c = base_t::GetController();
|
||||
ASSERT_LESS(index, c.GetUserMarkCount(), ());
|
||||
UserMark const * markForDelete = c.GetUserMark(index);
|
||||
|
||||
size_t animIndex = 0;
|
||||
for (; animIndex < m_anims.size(); ++animIndex)
|
||||
{
|
||||
TAnimNode const & anim = m_anims[animIndex];
|
||||
if (anim.first == markForDelete)
|
||||
{
|
||||
anim.second->Cancel();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (animIndex < m_anims.size())
|
||||
m_anims.erase(m_anims.begin() + animIndex);
|
||||
|
||||
c.DeleteUserMark(index);
|
||||
}
|
||||
|
||||
void BookmarkCategory::DeleteTrack(size_t index)
|
||||
{
|
||||
DeleteItem(m_tracks, index);
|
||||
}
|
||||
|
||||
size_t BookmarkCategory::GetBookmarksCount() const
|
||||
{
|
||||
return base_t::GetController().GetUserMarkCount();
|
||||
}
|
||||
|
||||
Bookmark const * BookmarkCategory::GetBookmark(size_t index) const
|
||||
{
|
||||
base_t::Controller const & c = base_t::GetController();
|
||||
return static_cast<Bookmark const *>(index < c.GetUserMarkCount() ? c.GetUserMark(index) : nullptr);
|
||||
}
|
||||
|
||||
Bookmark * BookmarkCategory::GetBookmark(size_t index)
|
||||
{
|
||||
base_t::Controller & c = base_t::GetController();
|
||||
return static_cast<Bookmark *>(index < c.GetUserMarkCount() ? c.GetUserMarkForEdit(index) : nullptr);
|
||||
}
|
||||
|
||||
size_t BookmarkCategory::FindBookmark(Bookmark const * bookmark) const
|
||||
{
|
||||
return base_t::GetController().FindUserMark(bookmark);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
string const kPlacemark = "Placemark";
|
||||
|
@ -227,6 +227,7 @@ namespace
|
|||
}
|
||||
|
||||
BookmarkCategory & m_category;
|
||||
UserMarksController & m_controller;
|
||||
|
||||
vector<string> m_tags;
|
||||
GeometryType m_geometryType;
|
||||
|
@ -362,11 +363,18 @@ namespace
|
|||
}
|
||||
|
||||
public:
|
||||
KMLParser(BookmarkCategory & cat) : m_category(cat)
|
||||
KMLParser(BookmarkCategory & cat)
|
||||
: m_category(cat)
|
||||
, m_controller(m_category.RequestController())
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
~KMLParser()
|
||||
{
|
||||
m_category.ReleaseController();
|
||||
}
|
||||
|
||||
bool Push(string const & name)
|
||||
{
|
||||
m_tags.push_back(name);
|
||||
|
@ -404,7 +412,10 @@ namespace
|
|||
if (MakeValid())
|
||||
{
|
||||
if (GEOMETRY_TYPE_POINT == m_geometryType)
|
||||
m_category.AddBookmark(m_org, BookmarkData(m_name, m_type, m_description, m_scale, m_timeStamp));
|
||||
{
|
||||
Bookmark * bm = static_cast<Bookmark *>(m_controller.CreateUserMark(m_org));
|
||||
bm->SetData(BookmarkData(m_name, m_type, m_description, m_scale, m_timeStamp));
|
||||
}
|
||||
else if (GEOMETRY_TYPE_LINE == m_geometryType)
|
||||
{
|
||||
Track track(m_points);
|
||||
|
@ -450,7 +461,7 @@ namespace
|
|||
if (currTag == "name")
|
||||
m_category.SetName(value);
|
||||
else if (currTag == "visibility")
|
||||
m_category.SetVisible(value == "0" ? false : true);
|
||||
m_controller.SetIsVisible(value == "0" ? false : true);
|
||||
}
|
||||
else if (prevTag == kPlacemark)
|
||||
{
|
||||
|
@ -562,31 +573,8 @@ string BookmarkCategory::GetDefaultType()
|
|||
return style::GetDefaultStyle();
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
struct AnimBlockGuard
|
||||
{
|
||||
public:
|
||||
AnimBlockGuard(bool & block)
|
||||
: m_block(block)
|
||||
{
|
||||
m_block = true;
|
||||
}
|
||||
|
||||
~AnimBlockGuard()
|
||||
{
|
||||
m_block = false;
|
||||
}
|
||||
|
||||
private:
|
||||
bool & m_block;
|
||||
};
|
||||
}
|
||||
|
||||
bool BookmarkCategory::LoadFromKML(ReaderPtr<Reader> const & reader)
|
||||
{
|
||||
AnimBlockGuard g(m_blockAnimation);
|
||||
|
||||
ReaderSource<ReaderPtr<Reader> > src(reader);
|
||||
KMLParser parser(*this);
|
||||
if (ParseXML(src, parser, true))
|
||||
|
@ -722,10 +710,10 @@ void BookmarkCategory::SaveToKML(ostream & s)
|
|||
// processed during the iteration. That's why i is initially set to
|
||||
// GetBookmarksCount() - 1, i.e. to the last bookmark in the
|
||||
// bookmarks list.
|
||||
for (size_t count = 0, i = GetBookmarksCount() - 1;
|
||||
count < GetBookmarksCount(); ++count, --i)
|
||||
for (size_t count = 0, i = GetUserMarkCount() - 1;
|
||||
count < GetUserMarkCount(); ++count, --i)
|
||||
{
|
||||
Bookmark const * bm = GetBookmark(i);
|
||||
Bookmark const * bm = static_cast<Bookmark const *>(GetUserMark(i));
|
||||
s << " <Placemark>\n";
|
||||
s << " <name>";
|
||||
SaveStringWithCDATA(s, bm->GetName());
|
||||
|
@ -844,33 +832,9 @@ string BookmarkCategory::GenerateUniqueFileName(const string & path, string name
|
|||
return (path + name + suffix + kmlExt);
|
||||
}
|
||||
|
||||
void BookmarkCategory::ReleaseAnimations()
|
||||
{
|
||||
vector<TAnimNode> tempAnims;
|
||||
for (size_t i = 0; i < m_anims.size(); ++i)
|
||||
{
|
||||
TAnimNode const & anim = m_anims[i];
|
||||
if (!anim.second->IsEnded() &&
|
||||
!anim.second->IsCancelled())
|
||||
{
|
||||
tempAnims.push_back(m_anims[i]);
|
||||
}
|
||||
}
|
||||
|
||||
swap(m_anims, tempAnims);
|
||||
}
|
||||
|
||||
UserMark * BookmarkCategory::AllocateUserMark(m2::PointD const & ptOrg)
|
||||
{
|
||||
Bookmark * b = new Bookmark(ptOrg, this);
|
||||
if (!m_blockAnimation)
|
||||
{
|
||||
shared_ptr<anim::Task> animTask = b->CreateAnimTask(m_framework);
|
||||
animTask->AddCallback(anim::Task::EEnded, bind(&BookmarkCategory::ReleaseAnimations, this));
|
||||
m_anims.push_back(make_pair((UserMark *)b, animTask));
|
||||
m_framework.GetAnimController()->AddTask(animTask);
|
||||
}
|
||||
return b;
|
||||
return new Bookmark(ptOrg, this);
|
||||
}
|
||||
|
||||
bool BookmarkCategory::SaveToKMLFile()
|
||||
|
|
|
@ -121,7 +121,7 @@ public:
|
|||
|
||||
class BookmarkCategory : public UserMarkContainer
|
||||
{
|
||||
typedef UserMarkContainer base_t;
|
||||
typedef UserMarkContainer TBase;
|
||||
/// @name Data
|
||||
//@{
|
||||
/// TODO move track into UserMarkContainer as a IDrawable custom data
|
||||
|
@ -133,22 +133,37 @@ class BookmarkCategory : public UserMarkContainer
|
|||
string m_file;
|
||||
|
||||
public:
|
||||
class Guard
|
||||
{
|
||||
public:
|
||||
Guard(BookmarkCategory & cat)
|
||||
: m_controller(cat.RequestController())
|
||||
, m_cat(cat)
|
||||
{
|
||||
}
|
||||
|
||||
~Guard()
|
||||
{
|
||||
m_cat.ReleaseController();
|
||||
}
|
||||
|
||||
UserMarksController & m_controller;
|
||||
|
||||
private:
|
||||
BookmarkCategory & m_cat;
|
||||
};
|
||||
|
||||
BookmarkCategory(string const & name, Framework & framework);
|
||||
~BookmarkCategory();
|
||||
|
||||
virtual Type GetType() const { return BOOKMARK_MARK; }
|
||||
virtual string const & GetSymbolName(size_t index) const;
|
||||
virtual dp::Anchor GetAnchor(size_t index) const;
|
||||
|
||||
void ClearBookmarks();
|
||||
void ClearTracks();
|
||||
|
||||
static string GetDefaultType();
|
||||
|
||||
/// @name Theese functions are called from Framework only.
|
||||
//@{
|
||||
Bookmark* AddBookmark(m2::PointD const & ptOrg, BookmarkData const & bm);
|
||||
void ReplaceBookmark(size_t index, BookmarkData const & bm);
|
||||
//@}
|
||||
|
||||
/// @name Tracks routine.
|
||||
//@{
|
||||
/// @note Move semantics is used here.
|
||||
|
@ -162,16 +177,6 @@ public:
|
|||
string const & GetName() const { return m_name; }
|
||||
string const & GetFileName() const { return m_file; }
|
||||
|
||||
size_t GetBookmarksCount() const;
|
||||
|
||||
Bookmark const * GetBookmark(size_t index) const;
|
||||
Bookmark * GetBookmark(size_t index);
|
||||
void DeleteBookmark(size_t index);
|
||||
|
||||
// Returns index of the bookmark if exists, otherwise returns
|
||||
// total number of bookmarks.
|
||||
size_t FindBookmark(Bookmark const * bookmark) const;
|
||||
|
||||
/// @name Theese fuctions are public for unit tests only.
|
||||
/// You don't need to call them from client code.
|
||||
//@{
|
||||
|
@ -192,17 +197,7 @@ public:
|
|||
//@}
|
||||
|
||||
protected:
|
||||
virtual string GetTypeName() const { return "search-result"; }
|
||||
virtual string GetActiveTypeName() const { return "search-result-active"; }
|
||||
virtual UserMark * AllocateUserMark(m2::PointD const & ptOrg);
|
||||
|
||||
private:
|
||||
void ReleaseAnimations();
|
||||
|
||||
private:
|
||||
bool m_blockAnimation;
|
||||
using TAnimNode = pair<UserMark *, shared_ptr<anim::Task>>;
|
||||
vector<TAnimNode> m_anims;
|
||||
};
|
||||
|
||||
/// <category index, bookmark index>
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
#include "graphics/depth_constants.hpp"
|
||||
|
||||
#include "render/route_renderer.hpp"
|
||||
|
||||
#include "platform/platform.hpp"
|
||||
#include "platform/settings.hpp"
|
||||
|
||||
|
@ -22,16 +20,13 @@
|
|||
BookmarkManager::BookmarkManager(Framework & f)
|
||||
: m_framework(f)
|
||||
, m_lastScale(1.0)
|
||||
, m_cache(NULL)
|
||||
, m_selection(f)
|
||||
, m_routeRenderer(new rg::RouteRenderer())
|
||||
{
|
||||
m_userMarkLayers.reserve(3);
|
||||
///@TODO UVR
|
||||
m_userMarkLayers.push_back(new SearchUserMarkContainer(0.0/*graphics::activePinDepth*/, m_framework));
|
||||
m_userMarkLayers.push_back(new ApiUserMarkContainer(0.0/*graphics::activePinDepth*/, m_framework));
|
||||
//m_userMarkLayers.push_back(new DebugUserMarkContainer(graphics::debugDepth, m_framework));
|
||||
UserMarkContainer::InitStaticMarks(FindUserMarksContainer(UserMarkContainer::SEARCH_MARK));
|
||||
UserMarkContainer::InitStaticMarks(FindUserMarksContainer(UserMarkType::SEARCH_MARK));
|
||||
}
|
||||
|
||||
BookmarkManager::~BookmarkManager()
|
||||
|
@ -40,7 +35,6 @@ BookmarkManager::~BookmarkManager()
|
|||
m_userMarkLayers.clear();
|
||||
|
||||
ClearItems();
|
||||
ResetScreen();
|
||||
}
|
||||
|
||||
namespace
|
||||
|
@ -189,42 +183,45 @@ void BookmarkManager::LoadBookmark(string const & filePath)
|
|||
m_categories.push_back(cat);
|
||||
}
|
||||
|
||||
size_t BookmarkManager::AddBookmark(size_t categoryIndex, const m2::PointD & ptOrg, BookmarkData & bm)
|
||||
size_t BookmarkManager::AddBookmark(size_t categoryIndex, m2::PointD const & ptOrg, BookmarkData & bm)
|
||||
{
|
||||
bm.SetTimeStamp(time(0));
|
||||
bm.SetScale(m_framework.GetDrawScale());
|
||||
|
||||
BookmarkCategory * pCat = m_categories[categoryIndex];
|
||||
Bookmark * bookmark = pCat->AddBookmark(ptOrg, bm);
|
||||
pCat->SetVisible(true);
|
||||
|
||||
BookmarkCategory::Guard guard(*pCat);
|
||||
static_cast<Bookmark *>(guard.m_controller.CreateUserMark(ptOrg))->SetData(bm);
|
||||
guard.m_controller.SetIsVisible(true);
|
||||
pCat->SaveToKMLFile();
|
||||
|
||||
m_lastCategoryUrl = pCat->GetFileName();
|
||||
m_lastType = bm.GetType();
|
||||
SaveState();
|
||||
|
||||
return pCat->FindBookmark(bookmark);
|
||||
return (pCat->GetUserMarkCount() - 1);
|
||||
}
|
||||
|
||||
size_t BookmarkManager::MoveBookmark(size_t bmIndex, size_t curCatIndex, size_t newCatIndex)
|
||||
{
|
||||
BookmarkCategory * cat = m_framework.GetBmCategory(curCatIndex);
|
||||
|
||||
Bookmark * bm = cat->GetBookmark(bmIndex);
|
||||
BookmarkCategory::Guard guard(*cat);
|
||||
Bookmark const * bm = static_cast<Bookmark const *>(guard.m_controller.GetUserMark(bmIndex));
|
||||
BookmarkData data = bm->GetData();
|
||||
m2::PointD ptOrg = bm->GetOrg();
|
||||
|
||||
cat->DeleteBookmark(bmIndex);
|
||||
guard.m_controller.DeleteUserMark(bmIndex);
|
||||
cat->SaveToKMLFile();
|
||||
|
||||
return m_framework.AddBookmark(newCatIndex, ptOrg, data);
|
||||
return AddBookmark(newCatIndex, ptOrg, data);
|
||||
}
|
||||
|
||||
void BookmarkManager::ReplaceBookmark(size_t catIndex, size_t bmIndex, BookmarkData const & bm)
|
||||
{
|
||||
BookmarkCategory * pCat = m_categories[catIndex];
|
||||
pCat->ReplaceBookmark(bmIndex, bm);
|
||||
pCat->SaveToKMLFile();
|
||||
BookmarkCategory * cat = m_categories[catIndex];
|
||||
BookmarkCategory::Guard guard(*cat);
|
||||
static_cast<Bookmark *>(guard.m_controller.GetUserMarkForEdit(bmIndex))->SetData(bm);
|
||||
cat->SaveToKMLFile();
|
||||
|
||||
m_lastType = bm.GetType();
|
||||
SaveState();
|
||||
|
@ -322,18 +319,12 @@ void BookmarkManager::DrawItems(Drawer * drawer) const
|
|||
void BookmarkManager::DeleteBmCategory(CategoryIter i)
|
||||
{
|
||||
BookmarkCategory * cat = *i;
|
||||
if (m_selection.m_container == cat)
|
||||
{
|
||||
PinClickManager & clikManager = m_framework.GetBalloonManager();
|
||||
clikManager.RemovePin();
|
||||
clikManager.Dismiss();
|
||||
}
|
||||
|
||||
m_categories.erase(i);
|
||||
cat->DeleteLater();
|
||||
FileWriter::DeleteFileX(cat->GetFileName());
|
||||
|
||||
delete cat;
|
||||
|
||||
m_categories.erase(i);
|
||||
if (cat->CanBeDeleted())
|
||||
delete cat;
|
||||
}
|
||||
|
||||
bool BookmarkManager::DeleteBmCategory(size_t index)
|
||||
|
@ -347,24 +338,25 @@ bool BookmarkManager::DeleteBmCategory(size_t index)
|
|||
return false;
|
||||
}
|
||||
|
||||
void BookmarkManager::ActivateMark(UserMark const * mark, bool needAnim)
|
||||
{
|
||||
m_selection.ActivateMark(mark, needAnim);
|
||||
}
|
||||
///@TODO UVR
|
||||
//void BookmarkManager::ActivateMark(UserMark const * mark, bool needAnim)
|
||||
//{
|
||||
// m_selection.ActivateMark(mark, needAnim);
|
||||
//}
|
||||
|
||||
bool BookmarkManager::UserMarkHasActive() const
|
||||
{
|
||||
return m_selection.IsActive();
|
||||
}
|
||||
//bool BookmarkManager::UserMarkHasActive() const
|
||||
//{
|
||||
// return m_selection.IsActive();
|
||||
//}
|
||||
|
||||
bool BookmarkManager::IsUserMarkActive(UserMark const * mark) const
|
||||
{
|
||||
if (mark == nullptr)
|
||||
return false;
|
||||
//bool BookmarkManager::IsUserMarkActive(UserMark const * mark) const
|
||||
//{
|
||||
// if (mark == nullptr)
|
||||
// return false;
|
||||
|
||||
return (m_selection.m_container == mark->GetContainer() &&
|
||||
m_selection.m_ptOrg.EqualDxDy(mark->GetOrg(), 1.0E-4));
|
||||
}
|
||||
// return (m_selection.m_container == mark->GetContainer() &&
|
||||
// m_selection.m_ptOrg.EqualDxDy(mark->GetOrg(), 1.0E-4));
|
||||
//}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -401,112 +393,65 @@ UserMark const * BookmarkManager::FindNearestUserMark(TTouchRectHolder const & h
|
|||
{
|
||||
BestUserMarkFinder finder(holder);
|
||||
for_each(m_categories.begin(), m_categories.end(), ref(finder));
|
||||
finder(FindUserMarksContainer(UserMarkContainer::API_MARK));
|
||||
finder(FindUserMarksContainer(UserMarkContainer::SEARCH_MARK));
|
||||
finder(FindUserMarksContainer(UserMarkType::API_MARK));
|
||||
finder(FindUserMarksContainer(UserMarkType::SEARCH_MARK));
|
||||
|
||||
return finder.GetFindedMark();
|
||||
}
|
||||
|
||||
void BookmarkManager::UserMarksSetVisible(UserMarkContainer::Type type, bool isVisible)
|
||||
{
|
||||
FindUserMarksContainer(type)->SetVisible(isVisible);
|
||||
}
|
||||
|
||||
bool BookmarkManager::UserMarksIsVisible(UserMarkContainer::Type type) const
|
||||
bool BookmarkManager::UserMarksIsVisible(UserMarkType type) const
|
||||
{
|
||||
return FindUserMarksContainer(type)->IsVisible();
|
||||
}
|
||||
|
||||
void BookmarkManager::UserMarksSetDrawable(UserMarkContainer::Type type, bool isDrawable)
|
||||
UserMarksController & BookmarkManager::UserMarksRequestController(UserMarkType type)
|
||||
{
|
||||
FindUserMarksContainer(type)->SetIsDrawable(isDrawable);
|
||||
return FindUserMarksContainer(type)->RequestController();
|
||||
}
|
||||
|
||||
void BookmarkManager::UserMarksIsDrawable(UserMarkContainer::Type type)
|
||||
void BookmarkManager::UserMarksReleaseController(UserMarksController & controller)
|
||||
{
|
||||
FindUserMarksContainer(type)->IsDrawable();
|
||||
FindUserMarksContainer(controller.GetType())->ReleaseController();
|
||||
}
|
||||
|
||||
UserMark * BookmarkManager::UserMarksAddMark(UserMarkContainer::Type type, const m2::PointD & ptOrg)
|
||||
void BookmarkManager::SetRouteTrack(Track & track)
|
||||
{
|
||||
return FindUserMarksContainer(type)->GetController().CreateUserMark(ptOrg);
|
||||
}
|
||||
|
||||
void BookmarkManager::UserMarksClear(UserMarkContainer::Type type, size_t skipCount/* = 0*/)
|
||||
{
|
||||
FindUserMarksContainer(type)->Clear(skipCount);
|
||||
}
|
||||
|
||||
UserMarkContainer::Controller & BookmarkManager::UserMarksGetController(UserMarkContainer::Type type)
|
||||
{
|
||||
return FindUserMarksContainer(type)->GetController();
|
||||
}
|
||||
|
||||
///@TODO UVR
|
||||
//void BookmarkManager::SetScreen(graphics::Screen * screen)
|
||||
//{
|
||||
// ResetScreen();
|
||||
// m_bmScreen = screen;
|
||||
// m_cache = new UserMarkDLCache(m_bmScreen);
|
||||
//}
|
||||
|
||||
void BookmarkManager::ResetScreen()
|
||||
{
|
||||
///@TODO UVR
|
||||
//delete m_cache;
|
||||
//m_cache = NULL;
|
||||
|
||||
//auto dlDeleteFn = [] (BookmarkCategory const * cat)
|
||||
//{
|
||||
// for (size_t j = 0; j < cat->GetTracksCount(); ++j)
|
||||
// cat->GetTrack(j)->CleanUp();
|
||||
//};
|
||||
|
||||
//if (m_bmScreen)
|
||||
//{
|
||||
// Delete display lists for all tracks
|
||||
// for_each(m_categories.begin(), m_categories.end(), dlDeleteFn);
|
||||
// m_routeRenderer->Clear();
|
||||
// m_bmScreen = 0;
|
||||
//}
|
||||
}
|
||||
|
||||
void BookmarkManager::SetRouteTrack(m2::PolylineD const & routePolyline, vector<double> const & turns,
|
||||
graphics::Color const & color)
|
||||
{
|
||||
m_routeRenderer->Setup(routePolyline, turns, color);
|
||||
m_routeTrack.reset();
|
||||
m_routeTrack.reset(track.CreatePersistent());
|
||||
}
|
||||
|
||||
void BookmarkManager::ResetRouteTrack()
|
||||
{
|
||||
m_routeRenderer->Clear();
|
||||
m_routeTrack.reset();
|
||||
}
|
||||
|
||||
void BookmarkManager::UpdateRouteDistanceFromBegin(double distance)
|
||||
UserMarkContainer const * BookmarkManager::FindUserMarksContainer(UserMarkType type) const
|
||||
{
|
||||
m_routeRenderer->UpdateDistanceFromBegin(distance);
|
||||
auto const iter = find_if(m_userMarkLayers.begin(), m_userMarkLayers.end(), [&type](UserMarkContainer const * cont)
|
||||
{
|
||||
return cont->GetType() == type;
|
||||
});
|
||||
ASSERT(iter != m_userMarkLayers.end(), ());
|
||||
return *iter;
|
||||
}
|
||||
|
||||
void BookmarkManager::SetRouteStartPoint(m2::PointD const & pt, bool isValid)
|
||||
UserMarkContainer * BookmarkManager::FindUserMarksContainer(UserMarkType type)
|
||||
{
|
||||
m_routeRenderer->SetRoutePoint(pt, true /* start */, isValid);
|
||||
auto iter = find_if(m_userMarkLayers.begin(), m_userMarkLayers.end(), [&type](UserMarkContainer * cont)
|
||||
{
|
||||
return cont->GetType() == type;
|
||||
});
|
||||
ASSERT(iter != m_userMarkLayers.end(), ());
|
||||
return *iter;
|
||||
}
|
||||
|
||||
void BookmarkManager::SetRouteFinishPoint(m2::PointD const & pt, bool isValid)
|
||||
UserMarkControllerGuard::UserMarkControllerGuard(BookmarkManager & mng, UserMarkType type)
|
||||
: m_mng(mng)
|
||||
, m_controller(mng.UserMarksRequestController(type))
|
||||
{
|
||||
m_routeRenderer->SetRoutePoint(pt, false /* start */, isValid);
|
||||
}
|
||||
|
||||
UserMarkContainer const * BookmarkManager::FindUserMarksContainer(UserMarkContainer::Type type) const
|
||||
UserMarkControllerGuard::~UserMarkControllerGuard()
|
||||
{
|
||||
ASSERT(type >= 0 && type < m_userMarkLayers.size(), ());
|
||||
ASSERT(m_userMarkLayers[(size_t)type]->GetType() == type, ());
|
||||
return m_userMarkLayers[(size_t)type];
|
||||
}
|
||||
|
||||
UserMarkContainer * BookmarkManager::FindUserMarksContainer(UserMarkContainer::Type type)
|
||||
{
|
||||
ASSERT(type >= 0 && type < m_userMarkLayers.size(), ());
|
||||
ASSERT(m_userMarkLayers[(size_t)type]->GetType() == type, ());
|
||||
return m_userMarkLayers[(size_t)type];
|
||||
m_mng.UserMarksReleaseController(m_controller);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include "map/bookmark.hpp"
|
||||
#include "map/route_track.hpp"
|
||||
#include "map/user_mark_container.hpp"
|
||||
#include "map/user_mark_dl_cache.hpp"
|
||||
|
||||
#include "std/function.hpp"
|
||||
#include "std/unique_ptr.hpp"
|
||||
|
@ -19,7 +18,7 @@ class BookmarkManager : private noncopyable
|
|||
|
||||
Framework & m_framework;
|
||||
|
||||
vector<UserMarkContainer * > m_userMarkLayers;
|
||||
vector<UserMarkContainer *> m_userMarkLayers;
|
||||
|
||||
mutable double m_lastScale;
|
||||
|
||||
|
@ -64,9 +63,9 @@ public:
|
|||
void DeleteBmCategory(CategoryIter i);
|
||||
bool DeleteBmCategory(size_t index);
|
||||
|
||||
void ActivateMark(UserMark const * mark, bool needAnim);
|
||||
bool UserMarkHasActive() const;
|
||||
bool IsUserMarkActive(UserMark const * container) const;
|
||||
//void ActivateMark(UserMark const * mark, bool needAnim);
|
||||
//bool UserMarkHasActive() const;
|
||||
//bool IsUserMarkActive(UserMark const * container) const;
|
||||
|
||||
typedef function<m2::AnyRectD const & (UserMarkContainer::Type)> TTouchRectHolder;
|
||||
|
||||
|
@ -74,17 +73,9 @@ public:
|
|||
UserMark const * FindNearestUserMark(TTouchRectHolder const & holder) const;
|
||||
|
||||
/// Additional layer methods
|
||||
void UserMarksSetVisible(UserMarkContainer::Type type, bool isVisible);
|
||||
bool UserMarksIsVisible(UserMarkContainer::Type type) const;
|
||||
void UserMarksSetDrawable(UserMarkContainer::Type type, bool isDrawable);
|
||||
void UserMarksIsDrawable(UserMarkContainer::Type type);
|
||||
UserMark * UserMarksAddMark(UserMarkContainer::Type type, m2::PointD const & ptOrg);
|
||||
void UserMarksClear(UserMarkContainer::Type type, size_t skipCount = 0);
|
||||
UserMarkContainer::Controller & UserMarksGetController(UserMarkContainer::Type type);
|
||||
|
||||
///@TODO UVR
|
||||
//void SetScreen(graphics::Screen * screen);
|
||||
void ResetScreen();
|
||||
bool UserMarksIsVisible(UserMarkType type) const;
|
||||
UserMarksController & UserMarksRequestController(UserMarkType type);
|
||||
void UserMarksReleaseController(UserMarksController & controller);
|
||||
|
||||
void SetRouteTrack(m2::PolylineD const & routePolyline, vector<double> const & turns,
|
||||
graphics::Color const & color);
|
||||
|
@ -94,12 +85,16 @@ public:
|
|||
void SetRouteFinishPoint(m2::PointD const & pt, bool isValid);
|
||||
|
||||
private:
|
||||
UserMarkContainer const * FindUserMarksContainer(UserMarkContainer::Type type) const;
|
||||
UserMarkContainer * FindUserMarksContainer(UserMarkContainer::Type type);
|
||||
|
||||
UserMarkDLCache * m_cache;
|
||||
|
||||
SelectionContainer m_selection;
|
||||
|
||||
unique_ptr<rg::RouteRenderer> m_routeRenderer;
|
||||
UserMarkContainer const * FindUserMarksContainer(UserMarkType type) const;
|
||||
UserMarkContainer * FindUserMarksContainer(UserMarkType type);
|
||||
};
|
||||
|
||||
class UserMarkControllerGuard
|
||||
{
|
||||
public:
|
||||
UserMarkControllerGuard(BookmarkManager & mng, UserMarkType type);
|
||||
~UserMarkControllerGuard();
|
||||
|
||||
BookmarkManager & m_mng;
|
||||
UserMarksController & m_controller;
|
||||
};
|
||||
|
|
|
@ -200,8 +200,6 @@ Framework::Framework()
|
|||
if (isBenchmarkingEnabled)
|
||||
m_benchmarkEngine = new BenchmarkEngine(this);
|
||||
|
||||
m_ParsedMapApi.SetController(&m_bmManager.UserMarksGetController(UserMarkContainer::API_MARK));
|
||||
|
||||
// Init strings bundle.
|
||||
// @TODO. There are hardcoded strings below which are defined in strings.txt as well.
|
||||
// It's better to use strings form strings.txt intead of hardcoding them here.
|
||||
|
@ -537,16 +535,17 @@ void Framework::ShowBookmark(BookmarkAndCategory const & bnc)
|
|||
StopLocationFollow();
|
||||
|
||||
// show ballon above
|
||||
Bookmark const * bmk = m_bmManager.GetBmCategory(bnc.first)->GetBookmark(bnc.second);
|
||||
Bookmark const * bmk = static_cast<Bookmark const *>(m_bmManager.GetBmCategory(bnc.first)->GetUserMark(bnc.second));
|
||||
|
||||
double scale = bmk->GetScale();
|
||||
if (scale == -1.0)
|
||||
scale = scales::GetUpperComfortScale();
|
||||
|
||||
ShowRectExVisibleScale(df::GetRectForDrawScale(scale, bmk->GetOrg()));
|
||||
Bookmark * mark = GetBmCategory(bnc.first)->GetBookmark(bnc.second);
|
||||
ActivateUserMark(mark);
|
||||
m_balloonManager.OnShowMark(mark);
|
||||
///@TODO UVR
|
||||
// ShowRectExVisibleScale(df::GetRectForDrawScale(scale, bmk->GetOrg()));
|
||||
// Bookmark * mark = GetBmCategory(bnc.first)->GetBookmark(bnc.second);
|
||||
// ActivateUserMark(mark);
|
||||
// m_balloonManager.OnShowMark(mark);
|
||||
}
|
||||
|
||||
void Framework::ShowTrack(Track const & track)
|
||||
|
@ -794,8 +793,7 @@ void Framework::ShowRect(m2::RectD rect)
|
|||
CheckMinGlobalRect(rect);
|
||||
|
||||
m_navigator.SetFromRect(m2::AnyRectD(rect));
|
||||
///@TODO UVR
|
||||
//Invalidate();
|
||||
UpdateEngineViewport();
|
||||
}
|
||||
|
||||
void Framework::ShowRectEx(m2::RectD rect)
|
||||
|
@ -826,9 +824,13 @@ void Framework::ShowRectFixedAR(m2::AnyRectD const & rect)
|
|||
etalonRect.Offset(pxCenter);
|
||||
|
||||
m_navigator.SetFromRects(rect, etalonRect);
|
||||
UpdateEngineViewport();
|
||||
}
|
||||
|
||||
///@TODO UVR
|
||||
//Invalidate();
|
||||
void Framework::UpdateEngineViewport()
|
||||
{
|
||||
if (!m_drapeEngine.IsNull())
|
||||
m_drapeEngine->UpdateCoverage(m_navigator.Screen());
|
||||
}
|
||||
|
||||
void Framework::StartInteractiveSearch(search::SearchParams const & params)
|
||||
|
@ -867,12 +869,7 @@ void Framework::UpdateSearchResults(search::Results const & results)
|
|||
void Framework::OnSearchResultsCallbackUI(search::Results const & results)
|
||||
{
|
||||
if (IsISActive())
|
||||
{
|
||||
FillSearchResultsMarks(results);
|
||||
|
||||
///@TODO UVR
|
||||
//Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void Framework::ClearAllCaches()
|
||||
|
@ -911,8 +908,7 @@ void Framework::EnterForeground()
|
|||
void Framework::ShowAll()
|
||||
{
|
||||
SetMaxWorldRect();
|
||||
///@TODO UVR
|
||||
//Invalidate();
|
||||
UpdateEngineViewport();
|
||||
}
|
||||
|
||||
/// @name Drag implementation.
|
||||
|
@ -1187,10 +1183,10 @@ void Framework::LoadSearchResultMetadata(search::Result & res) const
|
|||
|
||||
void Framework::ShowSearchResult(search::Result const & res)
|
||||
{
|
||||
UserMarkContainer::Type const type = UserMarkContainer::SEARCH_MARK;
|
||||
m_bmManager.UserMarksSetVisible(type, true);
|
||||
m_bmManager.UserMarksClear(type);
|
||||
m_bmManager.UserMarksSetDrawable(type, false);
|
||||
UserMarkControllerGuard guard(m_bmManager, UserMarkType::SEARCH_MARK);
|
||||
guard.m_controller.SetIsDrawable(false);
|
||||
guard.m_controller.Clear();
|
||||
guard.m_controller.SetIsVisible(true);
|
||||
|
||||
m_lastSearch.Clear();
|
||||
m_fixedSearchResults = 0;
|
||||
|
@ -1232,7 +1228,7 @@ void Framework::ShowSearchResult(search::Result const & res)
|
|||
search::AddressInfo info;
|
||||
info.MakeFrom(res);
|
||||
|
||||
SearchMarkPoint * mark = static_cast<SearchMarkPoint *>(m_bmManager.UserMarksAddMark(type, center));
|
||||
SearchMarkPoint * mark = static_cast<SearchMarkPoint *>(guard.m_controller.CreateUserMark(center));
|
||||
mark->SetInfo(info);
|
||||
|
||||
m_balloonManager.OnShowMark(mark);
|
||||
|
@ -1293,25 +1289,20 @@ size_t Framework::ShowAllSearchResults(search::Results const & results)
|
|||
viewport.SetSizesToIncludePoint(pt);
|
||||
|
||||
ShowRectFixedAR(viewport);
|
||||
///@TODO UVR
|
||||
//StopLocationFollow();
|
||||
}
|
||||
else
|
||||
minInd = -1;
|
||||
}
|
||||
|
||||
if (minInd == -1);
|
||||
///@TODO UVR
|
||||
//Invalidate();
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
void Framework::FillSearchResultsMarks(search::Results const & results)
|
||||
{
|
||||
UserMarkContainer::Type const type = UserMarkContainer::SEARCH_MARK;
|
||||
m_bmManager.UserMarksSetVisible(type, true);
|
||||
m_bmManager.UserMarksSetDrawable(type, true);
|
||||
m_bmManager.UserMarksClear(type, m_fixedSearchResults);
|
||||
UserMarkControllerGuard guard(m_bmManager, UserMarkType::SEARCH_MARK);
|
||||
guard.m_controller.SetIsVisible(true);
|
||||
guard.m_controller.SetIsDrawable(true);
|
||||
guard.m_controller.Clear(m_fixedSearchResults);
|
||||
|
||||
size_t const count = results.GetCount();
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
|
@ -1325,7 +1316,7 @@ void Framework::FillSearchResultsMarks(search::Results const & results)
|
|||
info.MakeFrom(r);
|
||||
|
||||
m2::PointD const pt = r.GetFeatureCenter();
|
||||
SearchMarkPoint * mark = static_cast<SearchMarkPoint *>(m_bmManager.UserMarksAddMark(type, pt));
|
||||
SearchMarkPoint * mark = static_cast<SearchMarkPoint *>(guard.m_controller.CreateUserMark(pt));
|
||||
mark->SetInfo(info);
|
||||
}
|
||||
}
|
||||
|
@ -1334,12 +1325,8 @@ void Framework::FillSearchResultsMarks(search::Results const & results)
|
|||
void Framework::CancelInteractiveSearch()
|
||||
{
|
||||
m_lastSearch.Clear();
|
||||
m_bmManager.UserMarksClear(UserMarkContainer::SEARCH_MARK);
|
||||
|
||||
UserMarkControllerGuard(m_bmManager, UserMarkType::SEARCH_MARK).m_controller.Clear();
|
||||
m_fixedSearchResults = 0;
|
||||
|
||||
///@TODO UVR
|
||||
//Invalidate();
|
||||
}
|
||||
|
||||
bool Framework::GetDistanceAndAzimut(m2::PointD const & point,
|
||||
|
@ -1398,6 +1385,11 @@ void Framework::CreateDrapeEngine(dp::RefPointer<dp::OGLContextFactory> contextF
|
|||
OnSize(w, h);
|
||||
}
|
||||
|
||||
dp::RefPointer<df::DrapeEngine> Framework::GetDrapeEngine()
|
||||
{
|
||||
return m_drapeEngine.GetRefPointer();
|
||||
}
|
||||
|
||||
void Framework::DestroyDrapeEngine()
|
||||
{
|
||||
m_drapeEngine.Destroy();
|
||||
|
@ -1475,18 +1467,22 @@ bool Framework::ShowMapForURL(string const & url)
|
|||
}
|
||||
else if (StartsWith(url, "mapswithme://") || StartsWith(url, "mwm://"))
|
||||
{
|
||||
m_bmManager.UserMarksClear(UserMarkContainer::API_MARK);
|
||||
UserMarkControllerGuard guard(m_bmManager, UserMarkType::API_MARK);
|
||||
guard.m_controller.Clear();
|
||||
|
||||
if (m_ParsedMapApi.SetUriAndParse(url))
|
||||
apiMark = url_scheme::ParseUrl(guard.m_controller, url, m_ParsedMapApi, rect);
|
||||
|
||||
if (m_ParsedMapApi.m_isValid)
|
||||
{
|
||||
if (!m_ParsedMapApi.GetViewportRect(rect))
|
||||
rect = df::GetWorldRect();
|
||||
|
||||
if ((apiMark = m_ParsedMapApi.GetSinglePoint()))
|
||||
guard.m_controller.SetIsVisible(true);
|
||||
guard.m_controller.SetIsDrawable(true);
|
||||
if (apiMark)
|
||||
result = NEED_CLICK;
|
||||
else
|
||||
result = NO_NEED_CLICK;
|
||||
}
|
||||
else
|
||||
guard.m_controller.SetIsVisible(false);
|
||||
}
|
||||
else // Actually, we can parse any geo url scheme with correct coordinates.
|
||||
{
|
||||
|
@ -1715,26 +1711,27 @@ Navigator & Framework::GetNavigator()
|
|||
|
||||
void Framework::ActivateUserMark(UserMark const * mark, bool needAnim)
|
||||
{
|
||||
if (mark != UserMarkContainer::UserMarkForMyPostion())
|
||||
DisconnectMyPositionUpdate();
|
||||
m_bmManager.ActivateMark(mark, needAnim);
|
||||
///@TODO UVR
|
||||
// if (mark != UserMarkContainer::UserMarkForMyPostion())
|
||||
// DisconnectMyPositionUpdate();
|
||||
// m_bmManager.ActivateMark(mark, needAnim);
|
||||
}
|
||||
|
||||
bool Framework::HasActiveUserMark() const
|
||||
{
|
||||
return m_bmManager.UserMarkHasActive();
|
||||
return false;
|
||||
///@TODO UVR
|
||||
//return m_bmManager.UserMarkHasActive();
|
||||
}
|
||||
|
||||
UserMark const * Framework::GetUserMark(m2::PointD const & pxPoint, bool isLongPress)
|
||||
{
|
||||
// The main idea is to calculate POI rank based on the frequency users are clicking them.
|
||||
UserMark const * mark = GetUserMarkWithoutLogging(pxPoint, isLongPress);
|
||||
|
||||
alohalytics::TStringMap details {{"isLongPress", isLongPress ? "1" : "0"}};
|
||||
if (mark)
|
||||
mark->FillLogEvent(details);
|
||||
alohalytics::Stats::Instance().LogEvent("$GetUserMark", details);
|
||||
|
||||
return mark;
|
||||
}
|
||||
|
||||
|
@ -1826,9 +1823,9 @@ BookmarkAndCategory Framework::FindBookmark(UserMark const * mark) const
|
|||
|
||||
ASSERT(result.first != empty.first, ());
|
||||
BookmarkCategory const * cat = GetBmCategory(result.first);
|
||||
for (size_t i = 0; i < cat->GetBookmarksCount(); ++i)
|
||||
for (size_t i = 0; i < cat->GetUserMarkCount(); ++i)
|
||||
{
|
||||
if (mark == cat->GetBookmark(i))
|
||||
if (mark == cat->GetUserMark(i))
|
||||
{
|
||||
result.second = i;
|
||||
break;
|
||||
|
@ -1878,7 +1875,7 @@ string Framework::CodeGe0url(double lat, double lon, double zoomLevel, string co
|
|||
|
||||
string Framework::GenerateApiBackUrl(ApiMarkPoint const & point)
|
||||
{
|
||||
string res = m_ParsedMapApi.GetGlobalBackUrl();
|
||||
string res = m_ParsedMapApi.m_globalBackUrl;
|
||||
if (!res.empty())
|
||||
{
|
||||
double lat, lon;
|
||||
|
|
|
@ -249,6 +249,7 @@ public:
|
|||
//@}
|
||||
|
||||
void CreateDrapeEngine(dp::RefPointer<dp::OGLContextFactory> contextFactory, float vs, int w, int h);
|
||||
dp::RefPointer<df::DrapeEngine> GetDrapeEngine();
|
||||
void DestroyDrapeEngine();
|
||||
|
||||
void SetMapStyle(MapStyle mapStyle);
|
||||
|
@ -385,6 +386,7 @@ private:
|
|||
|
||||
void ShowRectFixed(m2::RectD const & rect);
|
||||
void ShowRectFixedAR(m2::AnyRectD const & rect);
|
||||
void UpdateEngineViewport();
|
||||
|
||||
public:
|
||||
/// Show rect for point and needed draw scale.
|
||||
|
|
14
map/map.pro
14
map/map.pro
|
@ -15,10 +15,6 @@ HEADERS += \
|
|||
alfa_animation_task.hpp \
|
||||
anim_phase_chain.hpp \
|
||||
animator.hpp \
|
||||
api_mark_container.hpp \
|
||||
api_mark_point.hpp \
|
||||
benchmark_engine.hpp \
|
||||
benchmark_provider.hpp \
|
||||
bookmark.hpp \
|
||||
bookmark_manager.hpp \
|
||||
change_viewport_task.hpp \
|
||||
|
@ -38,11 +34,9 @@ HEADERS += \
|
|||
pin_click_manager.hpp \
|
||||
rotate_screen_task.hpp \
|
||||
ruler.hpp \
|
||||
styled_point.hpp \
|
||||
track.hpp \
|
||||
user_mark.hpp \
|
||||
user_mark_container.hpp \
|
||||
user_mark_dl_cache.hpp \
|
||||
|
||||
SOURCES += \
|
||||
../api/src/c/api-client.c \
|
||||
|
@ -51,9 +45,6 @@ SOURCES += \
|
|||
alfa_animation_task.cpp \
|
||||
anim_phase_chain.cpp \
|
||||
animator.cpp \
|
||||
api_mark_container.cpp \
|
||||
benchmark_engine.cpp \
|
||||
benchmark_provider.cpp \
|
||||
bookmark.cpp \
|
||||
bookmark_manager.cpp \
|
||||
change_viewport_task.cpp \
|
||||
|
@ -73,13 +64,10 @@ SOURCES += \
|
|||
pin_click_manager.cpp \
|
||||
rotate_screen_task.cpp \
|
||||
ruler.cpp \
|
||||
styled_point.cpp \
|
||||
track.cpp \
|
||||
user_mark.cpp \
|
||||
user_mark_container.cpp \
|
||||
user_mark_dl_cache.cpp \
|
||||
|
||||
!iphone*:!tizen*:!android* {
|
||||
HEADERS += qgl_render_context.hpp
|
||||
SOURCES += qgl_render_context.cpp
|
||||
QT += opengl
|
||||
}
|
||||
|
|
|
@ -120,21 +120,21 @@ char const * kmlString =
|
|||
|
||||
void CheckBookmarks(BookmarkCategory const & cat)
|
||||
{
|
||||
TEST_EQUAL(cat.GetBookmarksCount(), 4, ());
|
||||
TEST_EQUAL(cat.GetUserMarkCount(), 4, ());
|
||||
|
||||
Bookmark const * bm = cat.GetBookmark(3);
|
||||
Bookmark const * bm = static_cast<Bookmark const *>(cat.GetUserMark(3));
|
||||
TEST_EQUAL(bm->GetName(), "Nebraska", ());
|
||||
TEST_EQUAL(bm->GetType(), "placemark-red", ());
|
||||
TEST_EQUAL(bm->GetDescription(), "", ());
|
||||
TEST_EQUAL(bm->GetTimeStamp(), my::INVALID_TIME_STAMP, ());
|
||||
|
||||
bm = cat.GetBookmark(2);
|
||||
bm = static_cast<Bookmark const *>(cat.GetUserMark(2));
|
||||
TEST_EQUAL(bm->GetName(), "Monongahela National Forest", ());
|
||||
TEST_EQUAL(bm->GetType(), "placemark-pink", ());
|
||||
TEST_EQUAL(bm->GetDescription(), "Huttonsville, WV 26273<br>", ());
|
||||
TEST_EQUAL(bm->GetTimeStamp(), 524214643, ());
|
||||
|
||||
bm = cat.GetBookmark(1);
|
||||
bm = static_cast<Bookmark const *>(cat.GetUserMark(1));
|
||||
m2::PointD org = bm->GetOrg();
|
||||
TEST_ALMOST_EQUAL_ULPS(MercatorBounds::XToLon(org.x), 27.566765, ());
|
||||
TEST_ALMOST_EQUAL_ULPS(MercatorBounds::YToLat(org.y), 53.900047, ());
|
||||
|
@ -143,7 +143,7 @@ char const * kmlString =
|
|||
TEST_EQUAL(bm->GetDescription(), "", ());
|
||||
TEST_EQUAL(bm->GetTimeStamp(), 888888888, ());
|
||||
|
||||
bm = cat.GetBookmark(0);
|
||||
bm = static_cast<Bookmark const *>(cat.GetUserMark(0));
|
||||
org = bm->GetOrg();
|
||||
TEST_ALMOST_EQUAL_ULPS(MercatorBounds::XToLon(org.x), 27.551532, ());
|
||||
TEST_ALMOST_EQUAL_ULPS(MercatorBounds::YToLat(org.y), 53.89306, ());
|
||||
|
@ -172,12 +172,13 @@ UNIT_TEST(Bookmarks_ExportKML)
|
|||
|
||||
Framework framework;
|
||||
BookmarkCategory cat("Default", framework);
|
||||
BookmarkCategory::Guard guard(cat);
|
||||
TEST(cat.LoadFromKML(new MemReader(kmlString, strlen(kmlString))), ());
|
||||
CheckBookmarks(cat);
|
||||
|
||||
TEST_EQUAL(cat.IsVisible(), false, ());
|
||||
// Change visibility
|
||||
cat.SetVisible(true);
|
||||
guard.m_controller.SetIsVisible(true);
|
||||
TEST_EQUAL(cat.IsVisible(), true, ());
|
||||
|
||||
{
|
||||
|
@ -185,8 +186,8 @@ UNIT_TEST(Bookmarks_ExportKML)
|
|||
cat.SaveToKML(of);
|
||||
}
|
||||
|
||||
cat.ClearBookmarks();
|
||||
TEST_EQUAL(cat.GetBookmarksCount(), 0, ());
|
||||
guard.m_controller.Clear();
|
||||
TEST_EQUAL(guard.m_controller.GetUserMarkCount(), 0, ());
|
||||
|
||||
TEST(cat.LoadFromKML(new FileReader(BOOKMARKS_FILE_NAME)), ());
|
||||
CheckBookmarks(cat);
|
||||
|
@ -229,7 +230,7 @@ namespace
|
|||
UserMark const * mark = GetMark(fm, pt);
|
||||
ASSERT(mark != NULL, ());
|
||||
ASSERT(mark->GetContainer() != NULL, ());
|
||||
ASSERT(mark->GetContainer()->GetType() == UserMarkContainer::BOOKMARK_MARK, ());
|
||||
ASSERT(mark->GetContainer()->GetType() == UserMarkType::BOOKMARK_MARK, ());
|
||||
return static_cast<Bookmark const *>(mark);
|
||||
}
|
||||
|
||||
|
@ -241,7 +242,7 @@ namespace
|
|||
BookmarkCategory const * GetCategory(Bookmark const * bm)
|
||||
{
|
||||
ASSERT(bm->GetContainer() != NULL, ());
|
||||
ASSERT(bm->GetContainer()->GetType() == UserMarkContainer::BOOKMARK_MARK, ());
|
||||
ASSERT(bm->GetContainer()->GetType() == UserMarkType::BOOKMARK_MARK, ());
|
||||
return static_cast<BookmarkCategory const *>(bm->GetContainer());
|
||||
}
|
||||
|
||||
|
@ -251,7 +252,7 @@ namespace
|
|||
if (mark == NULL)
|
||||
return false;
|
||||
|
||||
if (mark->GetContainer()->GetType() != UserMarkContainer::BOOKMARK_MARK)
|
||||
if (mark->GetContainer()->GetType() != UserMarkType::BOOKMARK_MARK)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -281,17 +282,23 @@ UNIT_TEST(Bookmarks_Timestamp)
|
|||
// Check bookmarks order here. First added should be in the bottom of the list.
|
||||
TEST_EQUAL(fm.GetBmCategory(0)->GetBookmark(1), pBm, ());
|
||||
|
||||
TEST_EQUAL(fm.GetBmCategory(0)->GetBookmark(1)->GetName(), "name", ());
|
||||
TEST_EQUAL(fm.GetBmCategory(0)->GetBookmark(1)->GetType(), "type", ());
|
||||
Bookmark const * bm01 = static_cast<Bookmark const *>(fm.GetBmCategory(0)->GetUserMark(1));
|
||||
|
||||
TEST_EQUAL(fm.GetBmCategory(0)->GetBookmark(0)->GetName(), "newName", ());
|
||||
TEST_EQUAL(fm.GetBmCategory(0)->GetBookmark(0)->GetType(), "newType", ());
|
||||
TEST_EQUAL(bm01->GetName(), "name", ());
|
||||
TEST_EQUAL(bm01->GetType(), "type", ());
|
||||
|
||||
TEST_EQUAL(fm.GetBmCategory(1)->GetBookmark(0)->GetName(), "newName", ());
|
||||
TEST_EQUAL(fm.GetBmCategory(1)->GetBookmark(0)->GetType(), "newType", ());
|
||||
Bookmark const * bm00 = static_cast<Bookmark const *>(fm.GetBmCategory(0)->GetUserMark(0));
|
||||
|
||||
TEST_EQUAL(fm.GetBmCategory(0)->GetBookmarksCount(), 2, ());
|
||||
TEST_EQUAL(fm.GetBmCategory(1)->GetBookmarksCount(), 1, ());
|
||||
TEST_EQUAL(bm00->GetName(), "newName", ());
|
||||
TEST_EQUAL(bm00->GetType(), "newType", ());
|
||||
|
||||
Bookmark const * bm10 = static_cast<Bookmark const *>(fm.GetBmCategory(1)->GetUserMark(0));
|
||||
|
||||
TEST_EQUAL(bm10->GetName(), "newName", ());
|
||||
TEST_EQUAL(bm10->GetType(), "newType", ());
|
||||
|
||||
TEST_EQUAL(fm.GetBmCategory(0)->GetUserMarkCount(), 2, ());
|
||||
TEST_EQUAL(fm.GetBmCategory(1)->GetUserMarkCount(), 1, ());
|
||||
|
||||
DeleteCategoryFiles(arrCat);
|
||||
}
|
||||
|
@ -354,10 +361,11 @@ UNIT_TEST(Bookmarks_Getting)
|
|||
TEST_EQUAL(mark->GetName(), "4", ());
|
||||
TEST_EQUAL(mark->GetType(), "placemark-blue", ());
|
||||
|
||||
TEST_EQUAL(cat->GetBookmarksCount(), 2, ());
|
||||
TEST_EQUAL(cat->GetUserMarkCount(), 2, ());
|
||||
|
||||
fm.GetBmCategory(2)->DeleteBookmark(0);
|
||||
TEST_EQUAL(cat->GetBookmarksCount(), 1, ());
|
||||
BookmarkCategory::Guard guard(*fm.GetBmCategory(2));
|
||||
guard.m_controller.DeleteUserMark(0);
|
||||
TEST_EQUAL(cat->GetUserMarkCount(), 1, ());
|
||||
|
||||
DeleteCategoryFiles(arrCat);
|
||||
}
|
||||
|
@ -509,7 +517,7 @@ UNIT_TEST(Bookmarks_AddingMoving)
|
|||
mark = GetBookmarkPxPoint(fm, pixelPoint);
|
||||
cat = GetCategory(mark);
|
||||
TEST_EQUAL(cat->GetName(), arrCat[0], ());
|
||||
TEST_EQUAL(fm.GetBmCategory(0)->GetBookmarksCount(), 2,
|
||||
TEST_EQUAL(fm.GetBmCategory(0)->GetUserMarkCount(), 2,
|
||||
("Bookmark wasn't moved from one category to another"));
|
||||
TEST_EQUAL(mark->GetName(), "name2", ());
|
||||
TEST_EQUAL(mark->GetType(), "placemark-blue", ());
|
||||
|
@ -552,14 +560,17 @@ UNIT_TEST(Bookmarks_InnerFolder)
|
|||
BookmarkCategory cat("Default", framework);
|
||||
TEST(cat.LoadFromKML(new MemReader(kmlString2, strlen(kmlString2))), ());
|
||||
|
||||
TEST_EQUAL(cat.GetBookmarksCount(), 1, ());
|
||||
TEST_EQUAL(cat.GetUserMarkCount(), 1, ());
|
||||
}
|
||||
|
||||
UNIT_TEST(BookmarkCategory_EmptyName)
|
||||
{
|
||||
Framework framework;
|
||||
unique_ptr<BookmarkCategory> pCat(new BookmarkCategory("", framework));
|
||||
TEST(pCat->AddBookmark(m2::PointD(0, 0), BookmarkData("", "placemark-red")), ());
|
||||
{
|
||||
BookmarkCategory::Guard guard(*pCat);
|
||||
static_cast<Bookmark *>(guard.m_controller.CreateUserMark(m2::PointD(0, 0)))->SetData(BookmarkData("", "placemark-red"));
|
||||
}
|
||||
TEST(pCat->SaveToKMLFile(), ());
|
||||
|
||||
pCat->SetName("xxx");
|
||||
|
@ -611,18 +622,20 @@ UNIT_TEST(Bookmarks_SpecialXMLNames)
|
|||
BookmarkCategory cat1("", framework);
|
||||
TEST(cat1.LoadFromKML(new MemReader(kmlString3, strlen(kmlString3))), ());
|
||||
|
||||
TEST_EQUAL(cat1.GetBookmarksCount(), 1, ());
|
||||
TEST_EQUAL(cat1.GetUserMarkCount(), 1, ());
|
||||
TEST(cat1.SaveToKMLFile(), ());
|
||||
|
||||
unique_ptr<BookmarkCategory> const cat2(BookmarkCategory::CreateFromKMLFile(cat1.GetFileName(), framework));
|
||||
TEST(cat2.get(), ());
|
||||
TEST_EQUAL(cat2->GetBookmarksCount(), 1, ());
|
||||
TEST_EQUAL(cat2->GetUserMarkCount(), 1, ());
|
||||
|
||||
TEST_EQUAL(cat1.GetName(), "3663 and M & J Seafood Branches", ());
|
||||
TEST_EQUAL(cat1.GetName(), cat2->GetName(), ());
|
||||
TEST_EQUAL(cat1.GetFileName(), cat2->GetFileName(), ());
|
||||
TEST(EqualBookmarks(*cat1.GetBookmark(0), *cat2->GetBookmark(0)), ());
|
||||
TEST_EQUAL(cat1.GetBookmark(0)->GetName(), "![X1]{X2}(X3)", ());
|
||||
Bookmark const * bm1 = static_cast<Bookmark const *>(cat1.GetUserMark(0));
|
||||
Bookmark const * bm2 = static_cast<Bookmark const *>(cat2->GetUserMark(0));
|
||||
TEST(EqualBookmarks(*bm1, *bm2), ());
|
||||
TEST_EQUAL(bm1->GetName(), "![X1]{X2}(X3)", ());
|
||||
|
||||
TEST(my::DeleteFileX(cat1.GetFileName()), ());
|
||||
}
|
||||
|
|
|
@ -41,10 +41,10 @@ UNIT_TEST(KMZ_UnzipTest)
|
|||
|
||||
TEST_EQUAL(files.size(), 6, ("KMZ file wrong number of files"));
|
||||
|
||||
TEST_EQUAL(cat.GetBookmarksCount(), 6, ("Category wrong number of bookmarks"));
|
||||
TEST_EQUAL(cat.GetUserMarkCount(), 6, ("Category wrong number of bookmarks"));
|
||||
|
||||
{
|
||||
Bookmark const * bm = cat.GetBookmark(5);
|
||||
Bookmark const * bm = static_cast<Bookmark const *>(cat.GetUserMark(5));
|
||||
TEST_EQUAL(bm->GetName(), ("Lahaina Breakwall"), ("KML wrong name!"));
|
||||
TEST_EQUAL(bm->GetType(), "placemark-red", ("KML wrong type!"));
|
||||
TEST_ALMOST_EQUAL_ULPS(bm->GetOrg().x, -156.6777046791284, ("KML wrong org x!"));
|
||||
|
@ -52,7 +52,7 @@ UNIT_TEST(KMZ_UnzipTest)
|
|||
TEST_EQUAL(bm->GetScale(), -1, ("KML wrong scale!"));
|
||||
}
|
||||
{
|
||||
Bookmark const * bm = cat.GetBookmark(4);
|
||||
Bookmark const * bm = static_cast<Bookmark const *>(cat.GetUserMark(4));
|
||||
TEST_EQUAL(bm->GetName(), ("Seven Sacred Pools, Kipahulu"), ("KML wrong name!"));
|
||||
TEST_EQUAL(bm->GetType(), "placemark-red", ("KML wrong type!"));
|
||||
TEST_ALMOST_EQUAL_ULPS(bm->GetOrg().x, -156.0405130750025, ("KML wrong org x!"));
|
||||
|
|
|
@ -19,30 +19,26 @@ namespace
|
|||
lat = MercatorBounds::YToLat(MercatorBounds::LatToY(lat));
|
||||
}
|
||||
|
||||
const UserMarkContainer::Type type = UserMarkContainer::API_MARK;
|
||||
UserMarkType const type = UserMarkType::API_MARK;
|
||||
|
||||
class ApiTest
|
||||
{
|
||||
public:
|
||||
ApiTest(string const & uriString)
|
||||
{
|
||||
m_m = &m_fm.GetBookmarkManager();
|
||||
m_c = &m_m->UserMarksGetController(type);
|
||||
m_api.SetController(m_c);
|
||||
m_api.SetUriAndParse(uriString);
|
||||
UserMarkControllerGuard guard(*m_m, type);
|
||||
url_scheme::ParseUrl(guard.m_controller, uriString, m_api, m_viewportRect);
|
||||
}
|
||||
|
||||
bool IsValid() const { return m_api.IsValid(); }
|
||||
m2::RectD GetViewport()
|
||||
{
|
||||
m2::RectD rect;
|
||||
m_api.GetViewportRect(rect);
|
||||
return rect;
|
||||
}
|
||||
string const & GetAppTitle() { return m_api.GetAppTitle(); }
|
||||
bool GoBackOnBalloonClick() { return m_api.GoBackOnBalloonClick(); }
|
||||
int GetPointCount() { return m_c->GetUserMarkCount(); }
|
||||
string const & GetGlobalBackUrl() { return m_api.GetGlobalBackUrl(); }
|
||||
int GetApiVersion() { return m_api.GetApiVersion(); }
|
||||
bool IsValid() const { return m_api.m_isValid; }
|
||||
m2::RectD GetViewport() { return m_viewportRect; }
|
||||
|
||||
string const & GetAppTitle() { return m_api.m_appTitle; }
|
||||
bool GoBackOnBalloonClick() { return m_api.m_goBackOnBalloonClick; }
|
||||
int GetPointCount() { return UserMarkControllerGuard(*m_m, type).m_controller.GetUserMarkCount(); }
|
||||
string const & GetGlobalBackUrl() { return m_api.m_globalBackUrl; }
|
||||
int GetApiVersion() { return m_api.m_version; }
|
||||
bool TestLatLon(int index, double lat, double lon) const
|
||||
{
|
||||
double tLat, tLon;
|
||||
|
@ -63,26 +59,29 @@ namespace
|
|||
private:
|
||||
ApiMarkPoint const * GetMark(int index) const
|
||||
{
|
||||
TEST_LESS(index, m_c->GetUserMarkCount(), ());
|
||||
return static_cast<ApiMarkPoint const *>(m_c->GetUserMark(index));
|
||||
UserMarkControllerGuard guard(*m_m, type);
|
||||
TEST_LESS(index, guard.m_controller.GetUserMarkCount(), ());
|
||||
return static_cast<ApiMarkPoint const *>(guard.m_controller.GetUserMark(index));
|
||||
}
|
||||
|
||||
private:
|
||||
Framework m_fm;
|
||||
ParsedMapApi m_api;
|
||||
UserMarkContainer::Controller * m_c;
|
||||
m2::RectD m_viewportRect;
|
||||
BookmarkManager * m_m;
|
||||
};
|
||||
|
||||
bool IsValid(Framework & fm, string const & uriStrig)
|
||||
{
|
||||
ParsedMapApi api;
|
||||
UserMarkContainer::Type type = UserMarkContainer::API_MARK;
|
||||
api.SetController(&fm.GetBookmarkManager().UserMarksGetController(type));
|
||||
api.SetUriAndParse(uriStrig);
|
||||
bool res = api.IsValid();
|
||||
fm.GetBookmarkManager().UserMarksClear(type);
|
||||
return res;
|
||||
{
|
||||
UserMarkControllerGuard guard(fm.GetBookmarkManager(), UserMarkType::API_MARK);
|
||||
m2::RectD dummyRect;
|
||||
url_scheme::ParseUrl(guard.m_controller, uriStrig, api, dummyRect);
|
||||
guard.m_controller.Clear();
|
||||
}
|
||||
|
||||
return api.m_isValid;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
|
||||
#include "std/string.hpp"
|
||||
|
||||
class ScalesProcessor;
|
||||
|
||||
namespace url_scheme
|
||||
{
|
||||
|
||||
|
@ -20,40 +18,24 @@ struct ApiPoint
|
|||
string m_style;
|
||||
};
|
||||
|
||||
class Uri;
|
||||
|
||||
/// Handles [mapswithme|mwm]://map?params - everything related to displaying info on a map
|
||||
class ParsedMapApi
|
||||
struct ParsedMapApi
|
||||
{
|
||||
public:
|
||||
ParsedMapApi();
|
||||
|
||||
void SetController(UserMarkContainer::Controller * controller);
|
||||
|
||||
bool SetUriAndParse(string const & url);
|
||||
bool IsValid() const;
|
||||
string const & GetGlobalBackUrl() const { return m_globalBackUrl; }
|
||||
string const & GetAppTitle() const { return m_appTitle; }
|
||||
int GetApiVersion() const { return m_version; }
|
||||
void Reset();
|
||||
bool GoBackOnBalloonClick() const { return m_goBackOnBalloonClick; }
|
||||
|
||||
/// @name Used in settings map viewport after invoking API.
|
||||
bool GetViewportRect(m2::RectD & rect) const;
|
||||
UserMark const * GetSinglePoint() const;
|
||||
|
||||
private:
|
||||
bool Parse(Uri const & uri);
|
||||
void AddKeyValue(string key, string const & value, vector<ApiPoint> & points);
|
||||
|
||||
UserMarkContainer::Controller * m_controller;
|
||||
string m_globalBackUrl;
|
||||
string m_appTitle;
|
||||
int m_version;
|
||||
int m_version = 0;
|
||||
/// Zoom level in OSM format (e.g. from 1.0 to 20.0)
|
||||
/// Taken into an account when calculating viewport rect, but only if points count is == 1
|
||||
double m_zoomLevel;
|
||||
bool m_goBackOnBalloonClick;
|
||||
double m_zoomLevel = 0.0;
|
||||
bool m_goBackOnBalloonClick = false;
|
||||
bool m_isValid = false;
|
||||
};
|
||||
|
||||
/// Handles [mapswithme|mwm]://map?params - everything related to displaying info on a map
|
||||
/// apiData - extracted data from url. If apiData.m_isValid == true then returned mark or rect is valid
|
||||
/// If return nullptr and apiData.m_isValid == true, than more than one api point exists.
|
||||
/// In rect returned bound rect of api points
|
||||
/// If return not nullptr, than only one api point exists
|
||||
UserMark const * ParseUrl(UserMarksController & controller, string const & url,
|
||||
ParsedMapApi & apiData, m2::RectD & rect);
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ class Framework;
|
|||
class PaintEvent;
|
||||
namespace location { class GpsInfo; }
|
||||
namespace gui { class Element; }
|
||||
namespace url_scheme { struct ApiPoint; }
|
||||
|
||||
class PinClickManager
|
||||
{
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
#include "map/user_mark_container.hpp"
|
||||
|
||||
#include "map/framework.hpp"
|
||||
#include "map/anim_phase_chain.hpp"
|
||||
|
||||
#include "geometry/transformations.hpp"
|
||||
|
||||
#include "anim/task.hpp"
|
||||
#include "anim/controller.hpp"
|
||||
#include "drape_frontend/drape_engine.hpp"
|
||||
#include "drape_frontend/tile_key.hpp"
|
||||
#include "drape_frontend/user_mark_shapes.hpp"
|
||||
|
||||
#include "base/scope_guard.hpp"
|
||||
#include "base/macros.hpp"
|
||||
#include "base/stl_add.hpp"
|
||||
|
||||
|
@ -17,24 +16,24 @@
|
|||
|
||||
namespace
|
||||
{
|
||||
class PinAnimation : public AnimPhaseChain
|
||||
{
|
||||
public:
|
||||
PinAnimation(Framework & f)
|
||||
: AnimPhaseChain(f, m_scale)
|
||||
, m_scale(0.0)
|
||||
{
|
||||
InitDefaultPinAnim(this);
|
||||
}
|
||||
// class PinAnimation : public AnimPhaseChain
|
||||
// {
|
||||
// public:
|
||||
// PinAnimation(Framework & f)
|
||||
// : AnimPhaseChain(f, m_scale)
|
||||
// , m_scale(0.0)
|
||||
// {
|
||||
// InitDefaultPinAnim(this);
|
||||
// }
|
||||
|
||||
double GetScale() const
|
||||
{
|
||||
return m_scale;
|
||||
}
|
||||
// double GetScale() const
|
||||
// {
|
||||
// return m_scale;
|
||||
// }
|
||||
|
||||
private:
|
||||
double m_scale;
|
||||
};
|
||||
// private:
|
||||
// double m_scale;
|
||||
// };
|
||||
|
||||
class FindMarkFunctor
|
||||
{
|
||||
|
@ -67,107 +66,56 @@ namespace
|
|||
m2::PointD m_globalCenter;
|
||||
};
|
||||
|
||||
///@TODO UVR
|
||||
// void DrawUserMarkByPoint(double scale,
|
||||
// double visualScale,
|
||||
// m2::PointD const & pixelOfsset,
|
||||
// PaintOverlayEvent const & event,
|
||||
// graphics::DisplayList * dl,
|
||||
// m2::PointD const & ptOrg)
|
||||
// {
|
||||
//#ifndef USE_DRAPE
|
||||
// ScreenBase const & modelView = event.GetModelView();
|
||||
// graphics::Screen * screen = event.GetDrawer()->screen();
|
||||
// m2::PointD pxPoint = modelView.GtoP(ptOrg);
|
||||
// pxPoint += (pixelOfsset * visualScale);
|
||||
// math::Matrix<double, 3, 3> m = math::Shift(math::Scale(math::Identity<double, 3>(),
|
||||
// scale, scale),
|
||||
// pxPoint.x, pxPoint.y);
|
||||
// dl->draw(screen, m);
|
||||
//#endif // USE_DRAPE
|
||||
// }
|
||||
df::TileKey CreateTileKey(UserMarkContainer const * cont)
|
||||
{
|
||||
switch (cont->GetType())
|
||||
{
|
||||
case UserMarkType::API_MARK: return df::GetApiTileKey();
|
||||
case UserMarkType::SEARCH_MARK: return df::GetSearchTileKey();
|
||||
case UserMarkType::BOOKMARK_MARK: return df::GetBookmarkTileKey(reinterpret_cast<size_t>(cont));
|
||||
default:
|
||||
ASSERT(false, ());
|
||||
break;
|
||||
}
|
||||
|
||||
// void DrawUserMarkImpl(double scale,
|
||||
// double visualScale,
|
||||
// m2::PointD const & pixelOfsset,
|
||||
// PaintOverlayEvent const & event,
|
||||
// graphics::DisplayList * dl,
|
||||
// UserMark const * mark)
|
||||
// {
|
||||
// DrawUserMarkByPoint(scale, visualScale, pixelOfsset, event, dl, mark->GetOrg());
|
||||
// }
|
||||
return df::TileKey();
|
||||
}
|
||||
|
||||
// void DrawUserMark(double scale,
|
||||
// double visualScale,
|
||||
// PaintOverlayEvent const & event,
|
||||
// UserMarkDLCache * cache,
|
||||
// UserMarkDLCache::Key const & defaultKey,
|
||||
// UserMark const * mark)
|
||||
// {
|
||||
// if (mark->IsCustomDrawable())
|
||||
// {
|
||||
// ICustomDrawable const * drawable = static_cast<ICustomDrawable const *>(mark);
|
||||
// DrawUserMarkImpl(drawable->GetAnimScaleFactor(), visualScale, drawable->GetPixelOffset(), event, drawable->GetDisplayList(cache), mark);
|
||||
// }
|
||||
// else
|
||||
// DrawUserMarkImpl(scale, visualScale, m2::PointD(0.0, 0.0), event, cache->FindUserMark(defaultKey), mark);
|
||||
// }
|
||||
size_t const VisibleFlag = 0;
|
||||
size_t const VisibleDirtyFlag = 1;
|
||||
size_t const DrawableFlag = 2;
|
||||
size_t const DrawableDirtyFlag = 3;
|
||||
}
|
||||
|
||||
UserMarkContainer::UserMarkContainer(double layerDepth, Framework & fm)
|
||||
UserMarkContainer::UserMarkContainer(double layerDepth, UserMarkType type, Framework & fm)
|
||||
: m_framework(fm)
|
||||
, m_controller(this)
|
||||
, m_isVisible(true)
|
||||
, m_isDrawable(true)
|
||||
, m_layerDepth(layerDepth)
|
||||
, m_type(type)
|
||||
{
|
||||
m_flags.set();
|
||||
}
|
||||
|
||||
UserMarkContainer::~UserMarkContainer()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
template <class ToDo>
|
||||
void UserMarkContainer::ForEachInRect(m2::RectD const & rect, ToDo toDo) const
|
||||
{
|
||||
for (size_t i = 0; i < m_userMarks.size(); ++i)
|
||||
if (rect.IsPointInside(m_userMarks[i]->GetOrg()))
|
||||
toDo(m_userMarks[i].get());
|
||||
RequestController().Clear();
|
||||
ReleaseController();
|
||||
}
|
||||
|
||||
UserMark const * UserMarkContainer::FindMarkInRect(m2::AnyRectD const & rect, double & d) const
|
||||
{
|
||||
UserMark * mark = NULL;
|
||||
UserMark * mark = nullptr;
|
||||
if (IsVisible())
|
||||
{
|
||||
FindMarkFunctor f(&mark, d, rect);
|
||||
ForEachInRect(rect.GetGlobalRect(), f);
|
||||
for (size_t i = 0; i < m_userMarks.size(); ++i)
|
||||
{
|
||||
if (rect.IsPointInside(m_userMarks[i]->GetOrg()))
|
||||
f(m_userMarks[i]);
|
||||
}
|
||||
}
|
||||
return mark;
|
||||
}
|
||||
|
||||
void UserMarkContainer::Draw(PaintOverlayEvent const & e, UserMarkDLCache * cache) const
|
||||
{
|
||||
///@TODO UVR
|
||||
//#ifndef USE_DRAPE
|
||||
// if (IsVisible() && IsDrawable())
|
||||
// {
|
||||
// UserMarkDLCache::Key defaultKey(GetTypeName(), graphics::EPosCenter, m_layerDepth);
|
||||
// ForEachInRect(e.GetClipRect(), bind(&DrawUserMark, 1.0, m_framework.GetVisualScale(),
|
||||
// e, cache, defaultKey, _1));
|
||||
// }
|
||||
//#endif // USE_DRAPE
|
||||
}
|
||||
|
||||
void UserMarkContainer::Clear(size_t skipCount/* = 0*/)
|
||||
{
|
||||
// Recently added marks stored in the head of list
|
||||
// (@see CreateUserMark). Leave tail here.
|
||||
if (skipCount < m_userMarks.size())
|
||||
m_userMarks.erase(m_userMarks.begin(), m_userMarks.end() - skipCount);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
unique_ptr<PoiMarkPoint> g_selectionUserMark;
|
||||
|
@ -200,11 +148,69 @@ MyPositionMarkPoint * UserMarkContainer::UserMarkForMyPostion()
|
|||
return g_myPosition.get();
|
||||
}
|
||||
|
||||
UserMarksController & UserMarkContainer::RequestController()
|
||||
{
|
||||
BeginWrite();
|
||||
return *this;
|
||||
}
|
||||
|
||||
void UserMarkContainer::ReleaseController()
|
||||
{
|
||||
MY_SCOPE_GUARD(endWriteGuard, [this]{ EndWrite(); });
|
||||
dp::RefPointer<df::DrapeEngine> engine = m_framework.GetDrapeEngine();
|
||||
if (engine.IsNull())
|
||||
return;
|
||||
|
||||
df::TileKey key = CreateTileKey(this);
|
||||
if (IsVisibleFlagDirty() || IsDrawableFlagDirty())
|
||||
engine->ChangeVisibilityUserMarksLayer(key, IsVisible() && IsDrawable());
|
||||
|
||||
if (IsDirty())
|
||||
{
|
||||
if (GetUserMarkCount() == 0)
|
||||
engine->ClearUserMarksLayer(key);
|
||||
else
|
||||
engine->UpdateUserMarksLayer(key, this);
|
||||
}
|
||||
}
|
||||
|
||||
size_t UserMarkContainer::GetCount() const
|
||||
{
|
||||
return m_userMarks.size();
|
||||
}
|
||||
|
||||
m2::PointD const & UserMarkContainer::GetPivot(size_t index) const
|
||||
{
|
||||
return GetUserMark(index)->GetOrg();
|
||||
}
|
||||
|
||||
float UserMarkContainer::GetDepth(size_t index) const
|
||||
{
|
||||
UNUSED_VALUE(index);
|
||||
return m_layerDepth;
|
||||
}
|
||||
|
||||
dp::Anchor UserMarkContainer::GetAnchor(size_t index) const
|
||||
{
|
||||
UNUSED_VALUE(index);
|
||||
return dp::Center;
|
||||
}
|
||||
|
||||
bool UserMarkContainer::IsVisible() const
|
||||
{
|
||||
return m_flags[VisibleFlag];
|
||||
}
|
||||
|
||||
bool UserMarkContainer::IsDrawable() const
|
||||
{
|
||||
return m_flags[DrawableFlag];
|
||||
}
|
||||
|
||||
UserMark * UserMarkContainer::CreateUserMark(m2::PointD const & ptOrg)
|
||||
{
|
||||
// Push new marks to the head of list.
|
||||
m_userMarks.push_front(unique_ptr<UserMark>(AllocateUserMark(ptOrg)));
|
||||
return m_userMarks.front().get();
|
||||
SetDirty();
|
||||
m_userMarks.push_back(AllocateUserMark(ptOrg));
|
||||
return m_userMarks.back();
|
||||
}
|
||||
|
||||
size_t UserMarkContainer::GetUserMarkCount() const
|
||||
|
@ -215,58 +221,57 @@ size_t UserMarkContainer::GetUserMarkCount() const
|
|||
UserMark const * UserMarkContainer::GetUserMark(size_t index) const
|
||||
{
|
||||
ASSERT_LESS(index, m_userMarks.size(), ());
|
||||
return m_userMarks[index].get();
|
||||
return m_userMarks[index];
|
||||
}
|
||||
|
||||
UserMark * UserMarkContainer::GetUserMark(size_t index)
|
||||
UserMarkType UserMarkContainer::GetType() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
UserMark * UserMarkContainer::GetUserMarkForEdit(size_t index)
|
||||
{
|
||||
SetDirty();
|
||||
ASSERT_LESS(index, m_userMarks.size(), ());
|
||||
return m_userMarks[index].get();
|
||||
return m_userMarks[index];
|
||||
}
|
||||
|
||||
void UserMarkContainer::DeleteUserMark(size_t index)
|
||||
void UserMarkContainer::Clear(size_t skipCount/* = 0*/)
|
||||
{
|
||||
ASSERT_LESS(index, m_userMarks.size(), ());
|
||||
if (index < m_userMarks.size())
|
||||
m_userMarks.erase(m_userMarks.begin() + index);
|
||||
else
|
||||
LOG(LWARNING, ("Trying to delete non-existing item at index", index));
|
||||
SetDirty();
|
||||
for (size_t i = skipCount; i < m_userMarks.size(); ++i)
|
||||
delete m_userMarks[i];
|
||||
|
||||
if (skipCount < m_userMarks.size())
|
||||
m_userMarks.erase(m_userMarks.begin() + skipCount, m_userMarks.end());
|
||||
}
|
||||
|
||||
void UserMarkContainer::DeleteUserMark(UserMark const * mark)
|
||||
void UserMarkContainer::SetIsDrawable(bool isDrawable)
|
||||
{
|
||||
size_t index = FindUserMark(mark);
|
||||
if (index != m_userMarks.size())
|
||||
DeleteUserMark(index);
|
||||
if (IsDrawable() != isDrawable)
|
||||
{
|
||||
m_flags[DrawableDirtyFlag] = true;
|
||||
m_flags[DrawableFlag] = isDrawable;
|
||||
}
|
||||
}
|
||||
|
||||
size_t UserMarkContainer::FindUserMark(UserMark const * mark)
|
||||
void UserMarkContainer::SetIsVisible(bool isVisible)
|
||||
{
|
||||
auto it = find_if(m_userMarks.begin(), m_userMarks.end(), [&mark](unique_ptr<UserMark> const & p)
|
||||
{
|
||||
return p.get() == mark;
|
||||
});
|
||||
return distance(m_userMarks.begin(), it);
|
||||
if (IsVisible() != isVisible)
|
||||
{
|
||||
m_flags[VisibleDirtyFlag] = true;
|
||||
m_flags[VisibleFlag] = isVisible;
|
||||
}
|
||||
}
|
||||
|
||||
SearchUserMarkContainer::SearchUserMarkContainer(double layerDepth, Framework & framework)
|
||||
: UserMarkContainer(layerDepth, framework)
|
||||
bool UserMarkContainer::IsVisibleFlagDirty()
|
||||
{
|
||||
return m_flags[VisibleDirtyFlag];
|
||||
}
|
||||
|
||||
string SearchUserMarkContainer::GetTypeName() const
|
||||
bool UserMarkContainer::IsDrawableFlagDirty()
|
||||
{
|
||||
return "search-result";
|
||||
}
|
||||
|
||||
string SearchUserMarkContainer::GetActiveTypeName() const
|
||||
{
|
||||
return "search-result-active";
|
||||
}
|
||||
|
||||
UserMark * SearchUserMarkContainer::AllocateUserMark(const m2::PointD & ptOrg)
|
||||
{
|
||||
return new SearchMarkPoint(ptOrg, this);
|
||||
return m_flags[DrawableDirtyFlag];
|
||||
}
|
||||
|
||||
DebugUserMarkContainer::DebugUserMarkContainer(double layerDepth, Framework & framework)
|
||||
|
@ -291,70 +296,61 @@ UserMark * DebugUserMarkContainer::AllocateUserMark(const m2::PointD & ptOrg)
|
|||
return new DebugMarkPoint(ptOrg, this);
|
||||
}
|
||||
|
||||
|
||||
SelectionContainer::SelectionContainer(Framework & fm)
|
||||
: m_container(NULL)
|
||||
, m_fm(fm)
|
||||
namespace
|
||||
{
|
||||
}
|
||||
|
||||
void SelectionContainer::ActivateMark(UserMark const * userMark, bool needAnim)
|
||||
template <class T> void DeleteItem(vector<T> & v, size_t i)
|
||||
{
|
||||
if (needAnim)
|
||||
KillActivationAnim();
|
||||
if (userMark != NULL)
|
||||
if (i < v.size())
|
||||
{
|
||||
m_ptOrg = userMark->GetOrg();
|
||||
m_container = userMark->GetContainer();
|
||||
if (needAnim)
|
||||
StartActivationAnim();
|
||||
delete v[i];
|
||||
v.erase(v.begin() + i);
|
||||
}
|
||||
else
|
||||
m_container = NULL;
|
||||
}
|
||||
|
||||
void SelectionContainer::Draw(const PaintOverlayEvent & e, UserMarkDLCache * cache) const
|
||||
{
|
||||
///@TODO UVR
|
||||
// if (m_container != NULL)
|
||||
// {
|
||||
// UserMarkDLCache::Key defaultKey(m_container->GetActiveTypeName(),
|
||||
// graphics::EPosCenter,
|
||||
// graphics::activePinDepth);
|
||||
|
||||
// DrawUserMarkByPoint(GetActiveMarkScale(),
|
||||
// m_fm.GetVisualScale(),
|
||||
// m2::PointD(0, 0),
|
||||
// e, cache->FindUserMark(defaultKey),
|
||||
// m_ptOrg);
|
||||
// }
|
||||
}
|
||||
|
||||
bool SelectionContainer::IsActive() const
|
||||
{
|
||||
return m_container != NULL;
|
||||
}
|
||||
|
||||
void SelectionContainer::StartActivationAnim()
|
||||
{
|
||||
m_animTask.reset(new PinAnimation(m_fm));
|
||||
m_fm.GetAnimController()->AddTask(m_animTask);
|
||||
///@TODO UVR
|
||||
//m_fm.Invalidate();
|
||||
}
|
||||
|
||||
void SelectionContainer::KillActivationAnim()
|
||||
{
|
||||
m_animTask.reset();
|
||||
}
|
||||
|
||||
double SelectionContainer::GetActiveMarkScale() const
|
||||
{
|
||||
if (m_animTask != NULL)
|
||||
{
|
||||
PinAnimation * a = static_cast<PinAnimation *>(m_animTask.get());
|
||||
return a->GetScale();
|
||||
LOG(LWARNING, ("Trying to delete non-existing item at index", i));
|
||||
}
|
||||
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void UserMarkContainer::DeleteUserMark(size_t index)
|
||||
{
|
||||
SetDirty();
|
||||
ASSERT_LESS(index, m_userMarks.size(), ());
|
||||
DeleteItem(m_userMarks, index);
|
||||
}
|
||||
|
||||
SearchUserMarkContainer::SearchUserMarkContainer(double layerDepth, Framework & framework)
|
||||
: UserMarkContainer(layerDepth, UserMarkType::SEARCH_MARK, framework)
|
||||
{
|
||||
}
|
||||
|
||||
string const & SearchUserMarkContainer::GetSymbolName(size_t index) const
|
||||
{
|
||||
UNUSED_VALUE(index);
|
||||
static string s_symbol = "search-result";
|
||||
return s_symbol;
|
||||
}
|
||||
|
||||
UserMark * SearchUserMarkContainer::AllocateUserMark(const m2::PointD & ptOrg)
|
||||
{
|
||||
return new SearchMarkPoint(ptOrg, this);
|
||||
}
|
||||
|
||||
ApiUserMarkContainer::ApiUserMarkContainer(double layerDepth, Framework & framework)
|
||||
: UserMarkContainer(layerDepth, UserMarkType::API_MARK, framework)
|
||||
{
|
||||
}
|
||||
|
||||
string const & ApiUserMarkContainer::GetSymbolName(size_t index) const
|
||||
{
|
||||
UNUSED_VALUE(index);
|
||||
static string s_symbol = "api-result";
|
||||
return s_symbol;
|
||||
}
|
||||
|
||||
UserMark * ApiUserMarkContainer::AllocateUserMark(const m2::PointD & ptOrg)
|
||||
{
|
||||
return new ApiMarkPoint(ptOrg, this);
|
||||
}
|
||||
|
|
|
@ -1,119 +1,104 @@
|
|||
#pragma once
|
||||
|
||||
#include "user_mark.hpp"
|
||||
#include "user_mark_dl_cache.hpp"
|
||||
#include "map/events.hpp"
|
||||
#include "map/user_mark.hpp"
|
||||
|
||||
#include "render/events.hpp"
|
||||
#include "drape_frontend/user_marks_provider.hpp"
|
||||
|
||||
#include "geometry/point2d.hpp"
|
||||
#include "geometry/rect2d.hpp"
|
||||
|
||||
#include "std/deque.hpp"
|
||||
#include "std/bitset.hpp"
|
||||
|
||||
#include "std/noncopyable.hpp"
|
||||
#include "std/unique_ptr.hpp"
|
||||
|
||||
class Framework;
|
||||
|
||||
namespace anim
|
||||
enum class UserMarkType
|
||||
{
|
||||
class Task;
|
||||
}
|
||||
SEARCH_MARK,
|
||||
API_MARK,
|
||||
DEBUG_MARK,
|
||||
BOOKMARK_MARK
|
||||
};
|
||||
|
||||
class UserMarkContainer : private noncopyable
|
||||
class UserMarksController
|
||||
{
|
||||
public:
|
||||
virtual size_t GetUserMarkCount() const = 0;
|
||||
virtual UserMarkType GetType() const = 0;
|
||||
virtual void SetIsDrawable(bool isDrawable) = 0;
|
||||
virtual void SetIsVisible(bool isVisible) = 0;
|
||||
|
||||
virtual UserMark * CreateUserMark(m2::PointD const & ptOrg) = 0;
|
||||
virtual UserMark const * GetUserMark(size_t index) const = 0;
|
||||
virtual UserMark * GetUserMarkForEdit(size_t index) = 0;
|
||||
virtual void DeleteUserMark(size_t index) = 0;
|
||||
virtual void Clear(size_t skipCount = 0) = 0;
|
||||
};
|
||||
|
||||
class UserMarkContainer : public df::UserMarksProvider
|
||||
, protected UserMarksController
|
||||
, private noncopyable
|
||||
{
|
||||
public:
|
||||
using UserMarksListT = deque<unique_ptr<UserMark>>;
|
||||
|
||||
class Controller
|
||||
{
|
||||
public:
|
||||
Controller(UserMarkContainer * container)
|
||||
: m_container(container) {}
|
||||
|
||||
UserMark * CreateUserMark(m2::PointD const & ptOrg) { return m_container->CreateUserMark(ptOrg); }
|
||||
size_t GetUserMarkCount() const { return m_container->GetUserMarkCount(); }
|
||||
UserMark const * GetUserMark(size_t index) const { return m_container->GetUserMark(index); }
|
||||
UserMark * GetUserMarkForEdit(size_t index) { return m_container->GetUserMark(index); }
|
||||
void DeleteUserMark(size_t index) { m_container->DeleteUserMark(index); }
|
||||
void DeleteUserMark(UserMark const * mark) { m_container->DeleteUserMark(mark); }
|
||||
|
||||
// Returns index of the mark if exists, otherwise returns
|
||||
// number of user marks.
|
||||
size_t FindUserMark(UserMark const * mark) const { return m_container->FindUserMark(mark); }
|
||||
|
||||
private:
|
||||
UserMarkContainer * m_container;
|
||||
};
|
||||
|
||||
enum Type
|
||||
{
|
||||
SEARCH_MARK,
|
||||
API_MARK,
|
||||
DEBUG_MARK,
|
||||
BOOKMARK_MARK
|
||||
};
|
||||
|
||||
UserMarkContainer(double layerDepth, Framework & fm);
|
||||
UserMarkContainer(double layerDepth, UserMarkType type, Framework & fm);
|
||||
virtual ~UserMarkContainer();
|
||||
|
||||
//void SetScreen(graphics::Screen * cacheScreen);
|
||||
virtual Type GetType() const = 0;
|
||||
|
||||
bool IsVisible() const { return m_isVisible; }
|
||||
void SetVisible(bool isVisible) { m_isVisible = isVisible; }
|
||||
|
||||
bool IsDrawable() const { return m_isDrawable; }
|
||||
void SetIsDrawable(bool isDrawable) { m_isDrawable = isDrawable; }
|
||||
|
||||
// If not found mark on rect result is NULL
|
||||
// If not found mark on rect result is nullptr
|
||||
// If mark is found in "d" return distance from rect center
|
||||
// In multiple select choose mark with min(d)
|
||||
UserMark const * FindMarkInRect(m2::AnyRectD const & rect, double & d) const;
|
||||
|
||||
void Draw(PaintOverlayEvent const & e, UserMarkDLCache * cache) const;
|
||||
void ActivateMark(UserMark const * mark);
|
||||
void DiactivateMark();
|
||||
|
||||
void Clear(size_t skipCount = 0);
|
||||
|
||||
double GetDepth() const { return m_layerDepth; }
|
||||
|
||||
virtual UserMarkDLCache::Key GetDefaultKey() const;
|
||||
|
||||
static void InitStaticMarks(UserMarkContainer * container);
|
||||
static PoiMarkPoint * UserMarkForPoi();
|
||||
static MyPositionMarkPoint * UserMarkForMyPostion();
|
||||
|
||||
Controller const & GetController() const { return m_controller; }
|
||||
Controller & GetController() { return m_controller; }
|
||||
/// newer save reference on UserMarksController
|
||||
UserMarksController & RequestController();
|
||||
void ReleaseController();
|
||||
|
||||
virtual string GetActiveTypeName() const = 0;
|
||||
////////////////////////////////////////////////////////////
|
||||
size_t GetCount() const;
|
||||
m2::PointD const & GetPivot(size_t index) const;
|
||||
float GetDepth(size_t index) const;
|
||||
dp::Anchor GetAnchor(size_t index) const;
|
||||
|
||||
/// @TODO uvr : send event to drape to change visibility
|
||||
bool IsVisible() const;
|
||||
virtual bool IsDrawable() const;
|
||||
virtual size_t GetUserMarkCount() const;
|
||||
virtual UserMark const * GetUserMark(size_t index) const;
|
||||
virtual UserMarkType GetType() const override final;
|
||||
|
||||
protected:
|
||||
/// UserMarksController implementation
|
||||
virtual UserMark * CreateUserMark(m2::PointD const & ptOrg);
|
||||
virtual UserMark * GetUserMarkForEdit(size_t index);
|
||||
virtual void DeleteUserMark(size_t index);
|
||||
virtual void Clear(size_t skipCount = 0);
|
||||
virtual void SetIsDrawable(bool isDrawable);
|
||||
virtual void SetIsVisible(bool isVisible);
|
||||
|
||||
protected:
|
||||
virtual string GetTypeName() const = 0;
|
||||
virtual UserMark * AllocateUserMark(m2::PointD const & ptOrg) = 0;
|
||||
|
||||
private:
|
||||
friend class Controller;
|
||||
UserMark * CreateUserMark(m2::PointD const & ptOrg);
|
||||
size_t GetUserMarkCount() const;
|
||||
UserMark const * GetUserMark(size_t index) const;
|
||||
UserMark * GetUserMark(size_t index);
|
||||
void DeleteUserMark(size_t index);
|
||||
void DeleteUserMark(UserMark const * mark);
|
||||
size_t FindUserMark(UserMark const * mark);
|
||||
|
||||
template <class ToDo> void ForEachInRect(m2::RectD const & rect, ToDo toDo) const;
|
||||
|
||||
protected:
|
||||
Framework & m_framework;
|
||||
|
||||
private:
|
||||
Controller m_controller;
|
||||
bool m_isVisible;
|
||||
bool m_isDrawable;
|
||||
bool IsVisibleFlagDirty();
|
||||
bool IsDrawableFlagDirty();
|
||||
|
||||
private:
|
||||
bitset<4> m_flags;
|
||||
double m_layerDepth;
|
||||
UserMarksListT m_userMarks;
|
||||
UserMarkType m_type;
|
||||
};
|
||||
|
||||
class SearchUserMarkContainer : public UserMarkContainer
|
||||
|
@ -121,11 +106,20 @@ class SearchUserMarkContainer : public UserMarkContainer
|
|||
public:
|
||||
SearchUserMarkContainer(double layerDepth, Framework & framework);
|
||||
|
||||
virtual Type GetType() const { return SEARCH_MARK; }
|
||||
string const & GetSymbolName(size_t index) const;
|
||||
|
||||
protected:
|
||||
virtual UserMark * AllocateUserMark(m2::PointD const & ptOrg);
|
||||
};
|
||||
|
||||
class ApiUserMarkContainer : public UserMarkContainer
|
||||
{
|
||||
public:
|
||||
ApiUserMarkContainer(double layerDepth, Framework & framework);
|
||||
|
||||
string const & GetSymbolName(size_t index) const;
|
||||
|
||||
virtual string GetActiveTypeName() const;
|
||||
protected:
|
||||
virtual string GetTypeName() const;
|
||||
virtual UserMark * AllocateUserMark(m2::PointD const & ptOrg);
|
||||
};
|
||||
|
||||
|
@ -141,27 +135,3 @@ protected:
|
|||
virtual string GetTypeName() const;
|
||||
virtual UserMark * AllocateUserMark(m2::PointD const & ptOrg);
|
||||
};
|
||||
|
||||
class SelectionContainer
|
||||
{
|
||||
public:
|
||||
SelectionContainer(Framework & fm);
|
||||
|
||||
void ActivateMark(UserMark const * userMark, bool needAnim);
|
||||
void Draw(PaintOverlayEvent const & e, UserMarkDLCache * cache) const;
|
||||
bool IsActive() const;
|
||||
|
||||
private:
|
||||
/// animation support
|
||||
void StartActivationAnim();
|
||||
void KillActivationAnim();
|
||||
double GetActiveMarkScale() const;
|
||||
|
||||
shared_ptr<anim::Task> m_animTask;
|
||||
|
||||
private:
|
||||
friend class BookmarkManager;
|
||||
UserMarkContainer const * m_container;
|
||||
m2::PointD m_ptOrg;
|
||||
Framework & m_fm;
|
||||
};
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
#include "map/user_mark_dl_cache.hpp"
|
||||
|
||||
#include "base/stl_add.hpp"
|
||||
|
||||
UserMarkDLCache::UserMarkDLCache()
|
||||
{
|
||||
}
|
||||
|
||||
UserMarkDLCache::~UserMarkDLCache()
|
||||
{
|
||||
}
|
||||
|
||||
///@TODO UVR
|
||||
//graphics::DisplayList * UserMarkDLCache::FindUserMark(UserMarkDLCache::Key const & key)
|
||||
//{
|
||||
// node_t node = m_dls.find(key);
|
||||
// if (node != m_dls.end())
|
||||
// return node->second;
|
||||
|
||||
// return CreateDL(key);
|
||||
//}
|
||||
|
||||
namespace
|
||||
{
|
||||
///@TODO UVR
|
||||
// m2::RectD CalcCoords(double const & halfSizeX, double const & halfSizeY, graphics::EPosition anchor)
|
||||
// {
|
||||
// m2::RectD result(-halfSizeX, -halfSizeY, halfSizeX, halfSizeY);
|
||||
|
||||
// if (anchor & graphics::EPosAbove)
|
||||
// result.Offset(0.0, -halfSizeY);
|
||||
// else if (anchor & graphics::EPosUnder)
|
||||
// result.Offset(0.0, halfSizeY);
|
||||
|
||||
// if (anchor & graphics::EPosLeft)
|
||||
// result.Offset(halfSizeX, 0.0);
|
||||
// else if (anchor & graphics::EPosRight)
|
||||
// result.Offset(-halfSizeX, 0.0);
|
||||
|
||||
// return result;
|
||||
// }
|
||||
}
|
||||
|
||||
///@TODO UVR
|
||||
//graphics::DisplayList * UserMarkDLCache::CreateDL(UserMarkDLCache::Key const & key)
|
||||
//{
|
||||
// using namespace graphics;
|
||||
|
||||
// graphics::DisplayList * dl = m_cacheScreen->createDisplayList();
|
||||
// m_cacheScreen->beginFrame();
|
||||
// m_cacheScreen->setDisplayList(dl);
|
||||
|
||||
// Icon::Info infoKey(key.m_name);
|
||||
// Resource const * res = m_cacheScreen->fromID(m_cacheScreen->findInfo(infoKey));
|
||||
// shared_ptr<gl::BaseTexture> texture = m_cacheScreen->pipeline(res->m_pipelineID).texture();
|
||||
|
||||
// m2::RectU texRect = res->m_texRect;
|
||||
// m2::RectD coord = CalcCoords(texRect.SizeX() / 2.0, texRect.SizeY() / 2.0, key.m_anchor);
|
||||
|
||||
// m2::PointD coords[] =
|
||||
// {
|
||||
// coord.LeftBottom(),
|
||||
// coord.LeftTop(),
|
||||
// coord.RightBottom(),
|
||||
// coord.RightTop()
|
||||
// };
|
||||
// m2::PointF normal(0.0, 0.0);
|
||||
|
||||
// m2::PointF texCoords[] =
|
||||
// {
|
||||
// texture->mapPixel(m2::PointF(texRect.minX(), texRect.minY())),
|
||||
// texture->mapPixel(m2::PointF(texRect.minX(), texRect.maxY())),
|
||||
// texture->mapPixel(m2::PointF(texRect.maxX(), texRect.minY())),
|
||||
// texture->mapPixel(m2::PointF(texRect.maxX(), texRect.maxY()))
|
||||
// };
|
||||
|
||||
// m_cacheScreen->addTexturedStripStrided(coords, sizeof(m2::PointD),
|
||||
// &normal, 0,
|
||||
// texCoords, sizeof(m2::PointF),
|
||||
// 4, key.m_depthLayer, res->m_pipelineID);
|
||||
|
||||
// m_cacheScreen->setDisplayList(NULL);
|
||||
// m_cacheScreen->endFrame();
|
||||
|
||||
// m_dls.insert(make_pair(key, dl));
|
||||
|
||||
// return dl;
|
||||
//}
|
|
@ -1,43 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "drape/drape_global.hpp"
|
||||
|
||||
#include "base/math.hpp"
|
||||
|
||||
#include "std/map.hpp"
|
||||
|
||||
class UserMarkDLCache
|
||||
{
|
||||
public:
|
||||
struct Key
|
||||
{
|
||||
Key(string const & name, dp::Anchor anchor, double depthLayer)
|
||||
: m_name(name), m_anchor(anchor), m_depthLayer(depthLayer) {}
|
||||
|
||||
string m_name;
|
||||
dp::Anchor m_anchor;
|
||||
double m_depthLayer;
|
||||
|
||||
bool operator < (Key const & other) const
|
||||
{
|
||||
if (m_name != other.m_name)
|
||||
return m_name < other.m_name;
|
||||
if (!my::AlmostEqualULPs(m_depthLayer, other.m_depthLayer))
|
||||
return m_depthLayer < other.m_depthLayer;
|
||||
|
||||
return m_anchor < other.m_anchor;
|
||||
}
|
||||
};
|
||||
|
||||
UserMarkDLCache();
|
||||
~UserMarkDLCache();
|
||||
|
||||
///@TODO UVR
|
||||
//graphics::DisplayList * FindUserMark(Key const & key);
|
||||
|
||||
private:
|
||||
//graphics::DisplayList * CreateDL(Key const & key);
|
||||
|
||||
private:
|
||||
//graphics::Screen * m_cacheScreen;
|
||||
};
|
|
@ -103,9 +103,7 @@ namespace qt
|
|||
if (!m_framework->LoadState())
|
||||
ShowAll();
|
||||
else
|
||||
{
|
||||
UpdateScaleControl();
|
||||
}
|
||||
}
|
||||
|
||||
void DrawWidget::SaveState()
|
||||
|
@ -211,6 +209,7 @@ namespace qt
|
|||
dp::ThreadSafeFactory * factory = new dp::ThreadSafeFactory(new QtOGLContextFactory(this));
|
||||
m_contextFactory = dp::MasterPointer<dp::OGLContextFactory>(factory);
|
||||
CreateEngine();
|
||||
LoadState();
|
||||
UpdateScaleControl();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -177,7 +177,6 @@ void MainWindow::LoadState()
|
|||
{
|
||||
// do always show on full screen
|
||||
showMaximized();
|
||||
m_pDrawWidget->LoadState();
|
||||
}
|
||||
|
||||
void MainWindow::LocationStateModeChanged(location::State::Mode mode)
|
||||
|
|
Loading…
Add table
Reference in a new issue