mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-22 06:03:45 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
105
drape_frontend/map_shape.hpp
Normal file
105
drape_frontend/map_shape.hpp
Normal file
@@ -0,0 +1,105 @@
|
||||
#pragma once
|
||||
|
||||
#include "drape_frontend/message.hpp"
|
||||
#include "drape_frontend/tile_key.hpp"
|
||||
|
||||
#include "drape/graphics_context.hpp"
|
||||
#include "drape/pointers.hpp"
|
||||
|
||||
#include "geometry/point2d.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace dp
|
||||
{
|
||||
class Batcher;
|
||||
class TextureManager;
|
||||
} // namespace dp
|
||||
|
||||
namespace df
|
||||
{
|
||||
enum MapShapeType
|
||||
{
|
||||
GeometryType = 0,
|
||||
OverlayType,
|
||||
|
||||
MapShapeTypeCount
|
||||
};
|
||||
|
||||
class MapShape
|
||||
{
|
||||
public:
|
||||
virtual ~MapShape() = default;
|
||||
virtual void Prepare(ref_ptr<dp::TextureManager> /* textures */) const {}
|
||||
virtual void Draw(ref_ptr<dp::GraphicsContext> context, ref_ptr<dp::Batcher> batcher,
|
||||
ref_ptr<dp::TextureManager> textures) const = 0;
|
||||
virtual MapShapeType GetType() const { return MapShapeType::GeometryType; }
|
||||
|
||||
void SetFeatureMinZoom(int minZoom) { m_minZoom = minZoom; }
|
||||
int GetFeatureMinZoom() const { return m_minZoom; }
|
||||
|
||||
static m2::PointD ConvertToLocal(m2::PointD const & basePt, m2::PointD const & tileCenter, double scalar)
|
||||
{
|
||||
return (basePt - tileCenter) * scalar;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_minZoom = 0;
|
||||
};
|
||||
|
||||
using TMapShapes = std::vector<drape_ptr<MapShape>>;
|
||||
|
||||
class MapShapeMessage : public Message
|
||||
{
|
||||
public:
|
||||
explicit MapShapeMessage(TileKey const & key)
|
||||
: m_tileKey(key)
|
||||
{}
|
||||
|
||||
TileKey const & GetKey() const { return m_tileKey; }
|
||||
|
||||
private:
|
||||
TileKey m_tileKey;
|
||||
};
|
||||
|
||||
class TileReadStartMessage : public MapShapeMessage
|
||||
{
|
||||
public:
|
||||
explicit TileReadStartMessage(TileKey const & key) : MapShapeMessage(key) {}
|
||||
Type GetType() const override { return Type::TileReadStarted; }
|
||||
bool IsGraphicsContextDependent() const override { return true; }
|
||||
};
|
||||
|
||||
class TileReadEndMessage : public MapShapeMessage
|
||||
{
|
||||
public:
|
||||
explicit TileReadEndMessage(TileKey const & key) : MapShapeMessage(key) {}
|
||||
Type GetType() const override { return Type::TileReadEnded; }
|
||||
bool IsGraphicsContextDependent() const override { return true; }
|
||||
};
|
||||
|
||||
class MapShapeReadedMessage : public MapShapeMessage
|
||||
{
|
||||
public:
|
||||
MapShapeReadedMessage(TileKey const & key, TMapShapes && shapes)
|
||||
: MapShapeMessage(key), m_shapes(std::move(shapes))
|
||||
{}
|
||||
|
||||
Type GetType() const override { return Type::MapShapeReaded; }
|
||||
bool IsGraphicsContextDependent() const override { return true; }
|
||||
TMapShapes const & GetShapes() { return m_shapes; }
|
||||
|
||||
private:
|
||||
TMapShapes m_shapes;
|
||||
};
|
||||
|
||||
class OverlayMapShapeReadedMessage : public MapShapeReadedMessage
|
||||
{
|
||||
public:
|
||||
OverlayMapShapeReadedMessage(TileKey const & key, TMapShapes && shapes)
|
||||
: MapShapeReadedMessage(key, std::move(shapes))
|
||||
{}
|
||||
|
||||
Type GetType() const override { return Message::Type::OverlayMapShapeReaded; }
|
||||
};
|
||||
} // namespace df
|
||||
Reference in New Issue
Block a user