#pragma once #include "drape/batcher.hpp" #include "drape/render_bucket.hpp" #include "drape/render_state.hpp" #include "drape/texture_manager.hpp" #include "transit/transit_display_info.hpp" #include #include #include #include #include namespace df { extern int const kTransitSchemeMinZoomLevel; extern float const kTransitLineHalfWidth; extern std::vector const kTransitLinesWidthInPixel; struct TransitRenderData { enum class Type { LinesCaps, Lines, Markers, Text, Stubs }; Type m_type; dp::RenderState m_state; uint32_t m_recacheId; MwmSet::MwmId m_mwmId; m2::PointD m_pivot; drape_ptr m_bucket; TransitRenderData(Type type, dp::RenderState const & state, uint32_t recacheId, MwmSet::MwmId const & mwmId, m2::PointD const pivot, drape_ptr && bucket) : m_type(type) , m_state(state) , m_recacheId(recacheId) , m_mwmId(mwmId) , m_pivot(pivot) , m_bucket(std::move(bucket)) {} }; struct LineParams { LineParams() = default; LineParams(std::string const & color, float depth) : m_color(color), m_depth(depth) {} std::string m_color; float m_depth; }; struct ShapeParams { std::vector m_forwardLines; std::vector m_backwardLines; std::vector m_polyline; }; struct ShapeInfo { m2::PointD m_direction; size_t m_linesCount; }; struct StopInfo { StopInfo() = default; StopInfo(std::string const & name, FeatureID const & featureId) : m_name(name) , m_featureId(featureId) {} std::string m_name; FeatureID m_featureId; std::set m_lines; }; struct StopNodeParams { bool m_isTransfer = false; m2::PointD m_pivot; std::map m_shapesInfo; std::map m_stopsInfo; }; class TransitSchemeBuilder { public: enum class Priority : uint16_t { Default = 0, Stub = 1, StopMin = 2, StopMax = 30, TransferMin = 31, TransferMax = 60 }; using TFlushRenderDataFn = std::function; explicit TransitSchemeBuilder(TFlushRenderDataFn const & flushFn) : m_flushRenderDataFn(flushFn) {} void UpdateSchemes(ref_ptr context, TransitDisplayInfos const & transitDisplayInfos, ref_ptr textures); void RebuildSchemes(ref_ptr context, ref_ptr textures); void Clear(); void Clear(MwmSet::MwmId const & mwmId); private: struct MwmSchemeData { m2::PointD m_pivot; std::map m_lines; std::map m_shapes; std::map m_stops; std::map m_transfers; }; void BuildScheme(ref_ptr context, MwmSet::MwmId const & mwmId, ref_ptr textures); void CollectStops(TransitDisplayInfo const & transitDisplayInfo, MwmSet::MwmId const & mwmId, MwmSchemeData & scheme); void CollectLines(TransitDisplayInfo const & transitDisplayInfo, MwmSchemeData & scheme); void CollectShapes(TransitDisplayInfo const & transitDisplayInfo, MwmSchemeData & scheme); void FindShapes(routing::transit::StopId stop1Id, routing::transit::StopId stop2Id, routing::transit::LineId lineId, std::vector const & sameLines, TransitDisplayInfo const & transitDisplayInfo, MwmSchemeData & scheme); void AddShape(TransitDisplayInfo const & transitDisplayInfo, routing::transit::StopId stop1Id, routing::transit::StopId stop2Id, routing::transit::LineId lineId, MwmSchemeData & scheme); void PrepareScheme(MwmSchemeData & scheme); void GenerateShapes(ref_ptr context, MwmSet::MwmId const & mwmId); void GenerateStops(ref_ptr context, MwmSet::MwmId const & mwmId, ref_ptr textures); void GenerateMarker(ref_ptr context, m2::PointD const & pt, m2::PointD widthDir, float linesCountWidth, float linesCountHeight, float scaleWidth, float scaleHeight, float depth, dp::Color const & color, dp::Batcher & batcher); void GenerateTransfer(ref_ptr context, StopNodeParams const & params, m2::PointD const & pivot, dp::Batcher & batcher); void GenerateStop(ref_ptr context, StopNodeParams const & params, m2::PointD const & pivot, std::map const & lines, dp::Batcher & batcher); void GenerateTitles(ref_ptr context, StopNodeParams const & params, m2::PointD const & pivot, std::vector const & markerSizes, ref_ptr textures, dp::Batcher & batcher); void GenerateLine(ref_ptr context, std::vector const & path, m2::PointD const & pivot, dp::Color const & colorConst, float lineOffset, float halfWidth, float depth, dp::Batcher & batcher); using TransitSchemes = std::map; TransitSchemes m_schemes; TFlushRenderDataFn m_flushRenderDataFn; uint32_t m_recacheId = 0; }; } // namespace df