mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-24 20:21:52 +02:00
The location picker now shows the real topographic map instead of a hand-drawn outline, fetched as one WMS image for whatever box is on screen; the schematic border is gone and only the city list remains, to jump the view somewhere recognisable. Under the plan itself a georeferenced map gets the orthophoto, tiled through the layout library's own EPSG:2180 grid and cache. What a native build was missing is here: the download (WinHTTP, on worker threads), the decode and the texture. Finished transfers are handed back on the thread that drains them, so both the library's cache and the graphics API stay on one thread. The imagery service turns down browser user agents and fails the odd request even for a plain one, so requests go out as curl and are retried a few times. Starting a new map now drops the loaded scenery and comes back on empty ground, instead of leaving the previous scenery's contents under a plan that has nothing to do with them. The reload is deferred to the top of the frame: taking the editor off the mode stack while it is drawing its own panels would pull the ground out from under them.
85 lines
3.3 KiB
C++
85 lines
3.3 KiB
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "application/uilayer.h"
|
|
|
|
#include "editor/orthophoto.h"
|
|
#include "maj0sted/app/editor_document.hpp"
|
|
#include "maj0sted/web/editor.hpp"
|
|
|
|
// track layout tool: straights laid down by hand on the scenery itself and the curves fitted into
|
|
// the gaps between them. the panel holds only the controls - the drawing happens in the viewport,
|
|
// which the tool puts into a top-down orthographic view for the purpose. none of the geometry is
|
|
// computed here: maj0sted solves the whole document and the panel paints what comes back.
|
|
class plan_panel : public ui_panel
|
|
{
|
|
|
|
public:
|
|
plan_panel(std::string const &Name, bool const Isopen);
|
|
|
|
void update() override;
|
|
void render_contents() override;
|
|
|
|
private:
|
|
// methods
|
|
void render_toolbar();
|
|
void render_gaps();
|
|
void render_storage();
|
|
// asks what kind of scenery is being started, and where on the map it sits
|
|
void render_newmap_dialog();
|
|
void render_location_dialog();
|
|
// clears the drawing and sets the point of EPSG:2180 that the scenery's zero stands for
|
|
void start_map(bool const Georeferenced, double const Originx, double const Originy);
|
|
// paints the solved plan over the rendered scenery and takes the clicks that build it
|
|
void handle_scene();
|
|
void draw_on_scene();
|
|
// re-runs the solver over the whole document; cheap enough to do on every edit
|
|
void solve();
|
|
maj0sted::web::NiweletaSpec *current_niweleta();
|
|
maj0sted::web::NiweletaSpec const *current_niweleta() const;
|
|
// keeps exactly one fit slot per gap, so a gap's parameters survive edits to its neighbours
|
|
void align_fits();
|
|
// true when the solver actually produced the fit requested for the given gap
|
|
bool fit_applied(std::size_t const Gap) const;
|
|
// the panel edits a chained polyline, so a vertex is shared by the two straights meeting at it.
|
|
// the library allows fully independent straights; that freedom just isn't exposed here yet
|
|
std::size_t vertex_count() const;
|
|
void vertex_position(std::size_t const Index, double &X, double &Y) const;
|
|
void append_vertex(double const X, double const Y);
|
|
void move_vertex(std::size_t const Index, double const X, double const Y);
|
|
void drop_last_vertex();
|
|
// takes the camera to the middle of the drawing
|
|
void go_to_plan();
|
|
// members
|
|
maj0sted::app::EditorDocument m_document;
|
|
std::vector<maj0sted::web::NiweletaPolys> m_solved;
|
|
std::size_t m_niweleta{0}; // niweleta being drawn into
|
|
int m_draggedvertex{-1};
|
|
bool m_drawing{true}; // whether a click on the scenery lays track or only picks existing points
|
|
// first corner of a niweleta has nothing to attach to, so it waits for the second click
|
|
bool m_pending{false};
|
|
double m_pendingx{0.0};
|
|
double m_pendingy{0.0};
|
|
std::string m_status;
|
|
char m_path[256]{"editor/plan.m0s"};
|
|
// location picker: the point being considered, and the view over the schematic map of Poland
|
|
bool m_pickingplace{false};
|
|
double m_pickx{0.0};
|
|
double m_picky{0.0};
|
|
double m_mapviewx{0.0};
|
|
double m_mapviewy{0.0};
|
|
double m_mapscale{0.0};
|
|
// topographic base map behind the picker, and the orthophoto under the plan itself
|
|
editor::wms_image m_topomap{maj0sted::web::WmsConfig::geoportal_topo()};
|
|
editor::orthophoto_source m_ortho;
|
|
bool m_showortho{true};
|
|
};
|