18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 00:22:42 +01:00
Files
maszyna/editor/editorPhotoRules.hpp
T
maj00r 344e5eff3c feat(editor): no question of the terrain at the first L, it loads in the background and the photo doesn't wait for it
The first L in a new scenery with no tracks nor terrain asked in a window whether to load the terrain. Now nothing is asked:
where the scenery lies on the map the terrain model loads in the background around it, as the answer Load the terrain did, and
a line in the panel of the laying says "Terrain: loading..." with Without terrain, which stops it as that answer did; it goes
once the terrain is in. A scenery not placed on the map has Place it... there, to Terrain (F5). Whether a new scenery gets its
terrain by itself is a checkbox of the settings of the terrain loading, where the window had it. A download of the model that
failed is told there, and in the banner of the loading and the terrain panel, in plain words as the photo tells its own, not
as the code of WinHTTP (which stays in the log).

A tile of the photo no longer waits for the chunks of the terrain still to come under it: it lies flat at the height of the
ground found last (of the layer before any was) and goes onto the ground as it comes. The window and its strings are gone.
2026-11-24 01:29:32 +01:00

88 lines
4.0 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 <optional>
#include <string>
#include <utility>
#include <vector>
#include <glm/glm.hpp>
// the rules the aerial photo of the editor (editor_orthophoto) goes by, standing on their own: which origin of the scenery is
// taken, whether the photo is on, how the download area grows, when a tile is tried again, when the 4K photos come, and what a
// download that failed is told as
namespace photo_rules
{
// where the origin of the scenery comes from
enum class origin_source
{
none,
georeference, // //$g of the scenery file, as Rainsted and the wizard write it
mark, // //$o of the scenery, written by the editor
remembered // the settings of the editor, per scenery
};
struct origin_choice
{
glm::dvec2 origin{0.0}; // northing, easting
origin_source from{origin_source::none};
// with //$g, how far the other origin known (the one remembered or the one of //$o) lies from it, the farther; 0 when none
double differs{0.0};
};
// //$g goes first, as the file of the scenery says where it lies: an origin remembered by the editor for a scenery of the same name
// elsewhere, or one written into //$o with it, can't move it. Without //$g the editor's own //$o, then the one remembered
origin_choice choose_origin(std::optional<glm::dvec2> const &Georeference, std::optional<glm::dvec2> const &Mark, std::optional<glm::dvec2> const &Remembered);
// the origins further apart than that are told of
double constexpr origin_tolerance{1.0};
// the photo on or off: as the user left it in this scenery, else as the scenery keeps it (//$o on, the wizard writes it on),
// else off. Chosen: the terrain model doesn't turn it on by itself
struct switched
{
bool on{false};
bool chosen{false};
};
switched photo_on(std::optional<bool> const &User, std::optional<bool> const &Scenery);
// a tile which failed is tried again after that many seconds, doubling from 5 s up to 5 min, and never given up for good
double retry_delay(int Failures);
double constexpr retry_most{300.0};
// the 4K photos (6 cm/px) by themselves when the view is zoomed in that far, m a pixel; off again only once zoomed out past the
// second value, so they don't come and go at the edge
double constexpr hires_from{0.15};
double constexpr hires_until{0.25};
bool hires_wanted(double MetresPerPixel, bool Now);
// what a download that failed is told as, in plain words (an English message to be translated); the raw error is in the log
std::string failure_reason(std::string const &Error);
// of these, the failures of the connection and of the server alone, whatever was downloaded (the terrain model too); empty: the
// error isn't one of them
std::string connection_reason(std::string const &Error);
// the download area grown to where the camera or the laying goes: the tiles of the polygon (PUWG easting, northing) and the square of
// Reach tiles around the point, as one outline along the grid of the tiles, its holes filled. Only when the point is within Margin
// tiles of the tiles of the area and the square isn't in it already; not past Limit tiles in all
struct growth
{
std::vector<glm::dvec2> polygon; // empty: the area stays as it is
std::size_t added{0}; // tiles
std::size_t total{0}; // tiles of the area grown, or of the area as it is when it can't grow
bool limited{false}; // it would grow past the limit
};
growth grow_area(std::vector<glm::dvec2> const &Polygon, glm::dvec2 const &Point, double Tile, int Margin, int Reach, std::size_t Limit);
// the outline of a set of squares of a grid of the size, 4-connected and with no holes, a little inside their edges (Inset m), so
// the squares it touches are the ones of the set and none beside; empty when the set isn't one piece
std::vector<glm::dvec2> squares_outline(std::vector<std::pair<int, int>> const &Squares, double Size, double Inset);
} // namespace photo_rules