添加部分功能,以及等高线模型
This commit is contained in:
1 parent
8dcbd6f9d7
commit
663efa5c75
17 files changed
+407
-70
No files matched your search
@@ -21,7 +21,7 @@
|
||||
-->
|
||||
<AvaloniaVersion>11.3.9</AvaloniaVersion>
|
||||
<MvvmVersion>8.2.2</MvvmVersion>
|
||||
<Version>1.0.6</Version>
|
||||
<Version>1.0.7</Version>
|
||||
<Company>NeoRF</Company>
|
||||
<Product>Earth Model Studio</Product>
|
||||
<NeutralLanguage>zh-Hans</NeutralLanguage>
|
||||
|
||||
@@ -25,6 +25,6 @@
|
||||
"button": "#9FB4D4",
|
||||
"frame": "#0A1524"
|
||||
},
|
||||
"updatedAt": "2026-11-14T01:56:57Z",
|
||||
"build": "2baf95e031"
|
||||
"updatedAt": "2026-11-14T02:48:20Z",
|
||||
"build": "4d5485eed8"
|
||||
}
|
||||
Binary file not shown.
@@ -42,6 +42,17 @@
|
||||
"平原:海拔低、地面平坦,等高线很少甚至没有。"
|
||||
]
|
||||
},
|
||||
{
|
||||
"h": "地图上的教科书符号",
|
||||
"lines": [
|
||||
"分层设色:按固定高程档位套固定色阶(深绿→浅绿→绿→浅黄→黄→浅褐→褐→白),同一档内颜色完全相同。",
|
||||
"山峰用 ▲ 加高程数字标注。",
|
||||
"河流用蓝色线表示,沿谷底(等高线凸向高处的一侧)流。",
|
||||
"陡崖用红色锯齿线表示。",
|
||||
"指北针在图幅右上角,比例尺在左下角,分层设色图例在右下角。",
|
||||
"地形剖面图在图幅底部:沿南北中线剖开地面,标出各点海拔,看清起伏。"
|
||||
]
|
||||
},
|
||||
{
|
||||
"h": "容易出错的地方",
|
||||
"lines": [
|
||||
@@ -96,6 +107,17 @@
|
||||
"Plain: low and flat — few or no contour lines at all."
|
||||
]
|
||||
},
|
||||
{
|
||||
"h": "Textbook map symbols",
|
||||
"lines": [
|
||||
"Hypsometric tint: fixed colour bands by elevation (dark green → light green → green → pale yellow → yellow → light brown → brown → white); each band is a flat colour.",
|
||||
"Peaks are marked with a ▲ and their elevation.",
|
||||
"Rivers are drawn in blue along the valley floor (where contours bulge uphill).",
|
||||
"Cliffs are marked with a red saw-tooth line.",
|
||||
"A north arrow sits top-right, a scale bar bottom-left, and the tint legend bottom-right.",
|
||||
"The terrain profile along the bottom cuts the ground open and labels elevations, showing the relief at a glance."
|
||||
]
|
||||
},
|
||||
{
|
||||
"h": "Common mistakes",
|
||||
"lines": [
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 90 KiB |
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Media;
|
||||
@@ -244,6 +245,9 @@ public sealed class ContourView : Control
|
||||
// ---- 右侧:等高线俯视图 ----
|
||||
private void DrawContourMap(DrawingContext dc, Rect r)
|
||||
{
|
||||
// 底部预留剖面图的空间
|
||||
var profileH = Math.Min(132, r.Height * 0.30);
|
||||
if (profileH > 50) r = new Rect(r.X, r.Y, r.Width, r.Height - profileH);
|
||||
// 分层设色底图
|
||||
const int N = 96;
|
||||
for (var j = 0; j < N; j++)
|
||||
@@ -308,6 +312,60 @@ public sealed class ContourView : Control
|
||||
}
|
||||
}
|
||||
|
||||
// ── 教科书地形符号 ──
|
||||
|
||||
// 河流:蓝色线(沿谷底流)
|
||||
if (Field.River.Count > 1)
|
||||
{
|
||||
var geo = new StreamGeometry();
|
||||
using (var g = geo.Open())
|
||||
{
|
||||
g.BeginFigure(P(Field.River[0].U, Field.River[0].V), false);
|
||||
for (var i = 1; i < Field.River.Count; i++)
|
||||
g.LineTo(P(Field.River[i].U, Field.River[i].V));
|
||||
g.EndFigure(false);
|
||||
}
|
||||
var riverPen = new Pen(new SolidColorBrush(Color.Parse("#2F7FD0")), 2.2);
|
||||
riverPen.LineJoin = PenLineJoin.Round;
|
||||
riverPen.LineCap = PenLineCap.Round;
|
||||
dc.DrawGeometry(null, riverPen, geo);
|
||||
}
|
||||
|
||||
// 山峰:▲ + 高程数字(教科书标注法)
|
||||
foreach (var (pu, pv, ph) in Field.Peaks.Take(4))
|
||||
{
|
||||
var at = P(pu, pv);
|
||||
var tri = new StreamGeometry();
|
||||
using (var g = tri.Open())
|
||||
{
|
||||
g.BeginFigure(new Point(at.X, at.Y - 6), true);
|
||||
g.LineTo(new Point(at.X - 5.5, at.Y + 4));
|
||||
g.LineTo(new Point(at.X + 5.5, at.Y + 4));
|
||||
g.EndFigure(true);
|
||||
}
|
||||
dc.DrawGeometry(new SolidColorBrush(Color.Parse("#3A2A18")), null, tri);
|
||||
Text(dc, ((int)ph).ToString(), at.X + 8, at.Y - 8, 10, Color.Parse("#3A2A18"), true);
|
||||
}
|
||||
|
||||
// 陡崖:锯齿符号(教科书用锯齿线表示陡崖)
|
||||
foreach (var (cu, cv) in Field.Cliffs.Take(40))
|
||||
{
|
||||
var at = P(cu, cv);
|
||||
var saw = new StreamGeometry();
|
||||
using (var g = saw.Open())
|
||||
{
|
||||
g.BeginFigure(new Point(at.X - 3, at.Y + 3), false);
|
||||
for (var i = 0; i < 3; i++)
|
||||
{
|
||||
var x0 = at.X - 3 + i * 3;
|
||||
g.LineTo(new Point(x0 + 1.5, at.Y - 2));
|
||||
g.LineTo(new Point(x0 + 3, at.Y + 3));
|
||||
}
|
||||
g.EndFigure(false);
|
||||
}
|
||||
dc.DrawGeometry(null, new Pen(new SolidColorBrush(Color.Parse("#8B2E2E")), 1.4), saw);
|
||||
}
|
||||
|
||||
// 悬停十字
|
||||
if (_hasHover)
|
||||
{
|
||||
@@ -318,10 +376,165 @@ public sealed class ContourView : Control
|
||||
dc.DrawEllipse(new SolidColorBrush(Colors.White), new Pen(new SolidColorBrush(CAccent), 2), at, 5, 5);
|
||||
}
|
||||
|
||||
DrawNorthArrow(dc, r);
|
||||
DrawScaleBar(dc, r);
|
||||
DrawLegend(dc, r);
|
||||
DrawProfile(dc, r);
|
||||
|
||||
// 边框
|
||||
dc.DrawRectangle(null, new Pen(new SolidColorBrush(CLine), 1.2), r);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 地形剖面图(教科书等高线图必配):沿图幅中部的一条南北剖面线,
|
||||
/// 画出地面起伏并标注各点海拔。这是最能体现「等高线图 ↔ 立体地形」关系的图。
|
||||
/// </summary>
|
||||
private void DrawProfile(DrawingContext dc, Rect mapRect)
|
||||
{
|
||||
var h = Math.Min(132, mapRect.Height * 0.30);
|
||||
var r = new Rect(mapRect.X, mapRect.Bottom - h, mapRect.Width, h);
|
||||
if (r.Height < 50) return;
|
||||
|
||||
// 背景
|
||||
dc.FillRectangle(new SolidColorBrush(Color.FromArgb(235, 252, 250, 244)), r);
|
||||
dc.DrawRectangle(null, new Pen(new SolidColorBrush(Color.Parse("#2A3446")), 1.0), r);
|
||||
|
||||
// 纵轴比例:0 → 最大高程
|
||||
var maxH = Math.Max(1f, Field.MaxHeight);
|
||||
var baseY = r.Bottom - 18;
|
||||
var topY = r.Y + 16;
|
||||
|
||||
// 水平网格(每 200 m 一条)
|
||||
for (var hh = 200f; hh < maxH; hh += 200)
|
||||
{
|
||||
var gy = baseY - (hh / maxH) * (baseY - topY);
|
||||
dc.DrawLine(new Pen(new SolidColorBrush(Color.FromArgb(70, 42, 52, 70)), 0.8),
|
||||
new Point(r.X, gy), new Point(r.Right, gy));
|
||||
Text(dc, $"{hh:0}", r.X + 2, gy - 8, 7.5, Color.Parse("#5A6B80"));
|
||||
}
|
||||
// 基准线
|
||||
dc.DrawLine(new Pen(new SolidColorBrush(Color.Parse("#2A3446")), 1.2),
|
||||
new Point(r.X, baseY), new Point(r.Right, baseY));
|
||||
|
||||
// 剖面线:沿图幅中部(v = 0.5)自西向东
|
||||
const int N = 160;
|
||||
var geo = new StreamGeometry();
|
||||
using (var g = geo.Open())
|
||||
{
|
||||
for (var i = 0; i <= N; i++)
|
||||
{
|
||||
var u = (double)i / N;
|
||||
var hv = Field.SampleSmooth(u, 0.5);
|
||||
var y = baseY - (hv / maxH) * (baseY - topY);
|
||||
var x = r.X + u * r.Width;
|
||||
if (i == 0) g.BeginFigure(new Point(x, y), false);
|
||||
else g.LineTo(new Point(x, y));
|
||||
}
|
||||
g.EndFigure(false);
|
||||
}
|
||||
dc.DrawGeometry(null, new Pen(new SolidColorBrush(Color.Parse("#B03A2E")), 2.0), geo);
|
||||
|
||||
// 剖面线上的几个关键点(与等高线图上的位置对应)
|
||||
var marks = new[] { 0.0, 0.25, 0.5, 0.75, 1.0 };
|
||||
foreach (var u in marks)
|
||||
{
|
||||
var hv = Field.SampleSmooth(u, 0.5);
|
||||
var y = baseY - (hv / maxH) * (baseY - topY);
|
||||
var x = r.X + u * r.Width;
|
||||
dc.DrawEllipse(new SolidColorBrush(Color.Parse("#B03A2E")), null, new Point(x, y), 3, 3);
|
||||
Text(dc, $"{hv:0}", x, y - 13, 8, Color.Parse("#8B2E24"), true, TextAlignment.Center);
|
||||
}
|
||||
|
||||
// 标注:剖面线在图上的位置
|
||||
Text(dc, T("profile.title"), r.X + 6, r.Y + 3, 9, Color.Parse("#2A3446"), true);
|
||||
dc.DrawLine(new Pen(new SolidColorBrush(Color.Parse("#2A3446")), 1.2, dashStyle: DashStyle.Dash),
|
||||
new Point(r.X + r.Width / 2, mapRect.Y), new Point(r.X + r.Width / 2, r.Y));
|
||||
}
|
||||
|
||||
/// <summary>指北针(教科书地图必备,位于图幅右上角)。</summary>
|
||||
private void DrawNorthArrow(DrawingContext dc, Rect r)
|
||||
{
|
||||
var x = r.Right - 26;
|
||||
var y = r.Y + 20;
|
||||
var tri = new StreamGeometry();
|
||||
using (var g = tri.Open())
|
||||
{
|
||||
g.BeginFigure(new Point(x, y - 12), true);
|
||||
g.LineTo(new Point(x - 5, y + 6));
|
||||
g.LineTo(new Point(x, y + 2));
|
||||
g.EndFigure(true);
|
||||
}
|
||||
dc.DrawGeometry(new SolidColorBrush(Color.Parse("#2A3446")), null, tri);
|
||||
var tri2 = new StreamGeometry();
|
||||
using (var g2 = tri2.Open())
|
||||
{
|
||||
g2.BeginFigure(new Point(x, y - 12), true);
|
||||
g2.LineTo(new Point(x + 5, y + 6));
|
||||
g2.LineTo(new Point(x, y + 2));
|
||||
g2.EndFigure(true);
|
||||
}
|
||||
dc.DrawGeometry(new SolidColorBrush(Color.Parse("#8FA0B8")), null, tri2);
|
||||
Text(dc, "N", x, y + 8, 9.5, Color.Parse("#2A3446"), true, TextAlignment.Center);
|
||||
}
|
||||
|
||||
/// <summary>比例尺(教科书地图必备,左下角)。</summary>
|
||||
private void DrawScaleBar(DrawingContext dc, Rect r)
|
||||
{
|
||||
var x = r.X + 14;
|
||||
var y = r.Bottom - 22;
|
||||
var w = 90.0;
|
||||
var h = 5.0;
|
||||
|
||||
// 分黑白相间的格(教科书比例尺画法)
|
||||
for (var i = 0; i < 4; i++)
|
||||
{
|
||||
var seg = new Rect(x + i * w / 4, y, w / 4, h);
|
||||
dc.FillRectangle(new SolidColorBrush(i % 2 == 0
|
||||
? Color.Parse("#2A3446") : Color.Parse("#FFFFFF")), seg);
|
||||
dc.DrawRectangle(new Pen(new SolidColorBrush(Color.Parse("#2A3446")), 0.8), seg);
|
||||
}
|
||||
Text(dc, "0", x, y - 11, 8.5, Color.Parse("#2A3446"), align: TextAlignment.Center);
|
||||
Text(dc, "1 km", x + w, y - 11, 8.5, Color.Parse("#2A3446"), align: TextAlignment.Center);
|
||||
}
|
||||
|
||||
/// <summary>分层设色图例(教科书右下角的色阶表)。</summary>
|
||||
private void DrawLegend(DrawingContext dc, Rect r)
|
||||
{
|
||||
var bands = new (float From, float To)[]
|
||||
{
|
||||
(0, 200), (200, 400), (400, 600), (600, 800),
|
||||
(800, 1000), (1000, 1200), (1200, 1400), (1400, 1600), (1600, 2000)
|
||||
};
|
||||
|
||||
var w = 62.0;
|
||||
var rowH = 11.0;
|
||||
var h = bands.Length * rowH + 16;
|
||||
var x = r.Right - w - 12;
|
||||
var y = r.Bottom - h - 12;
|
||||
|
||||
dc.DrawRectangle(new SolidColorBrush(Color.FromArgb(210, 255, 255, 255)), null,
|
||||
new Rect(x, y, w, h));
|
||||
dc.DrawRectangle(null, new Pen(new SolidColorBrush(Color.Parse("#2A3446")), 0.9),
|
||||
new Rect(x, y, w, h));
|
||||
|
||||
Text(dc, T("legend.title"), x + 5, y + 3, 8.5, Color.Parse("#2A3446"), true);
|
||||
|
||||
for (var i = 0; i < bands.Length; i++)
|
||||
{
|
||||
var (from, to) = bands[i];
|
||||
var mid = (from + to) / 2;
|
||||
var (cr, cg, cb) = TerrainAnalyzer.ColorForHeight(mid, 0, 2000);
|
||||
var cy = y + 14 + i * rowH;
|
||||
dc.FillRectangle(new SolidColorBrush(Color.FromRgb(cr, cg, cb)),
|
||||
new Rect(x + 5, cy, 14, rowH - 2));
|
||||
dc.DrawRectangle(null, new Pen(new SolidColorBrush(Color.Parse("#2A3446")), 0.6),
|
||||
new Rect(x + 5, cy, 14, rowH - 2));
|
||||
|
||||
var label = to >= 2000 ? ">1600 m" : $"{from:0}–{to:0} m";
|
||||
Text(dc, label, x + 23, cy, 8, Color.Parse("#2A3446"));
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- 文字
|
||||
|
||||
private void Text(DrawingContext dc, string s, double x, double y, double size, Color color,
|
||||
|
||||
@@ -15,6 +15,8 @@ internal static class DefaultTexts
|
||||
["kind.hill"] = "丘陵",
|
||||
["kind.plateau"] = "高原",
|
||||
["kind.plain"] = "平原",
|
||||
["legend.title"] = "分层设色",
|
||||
["profile.title"] = "地形剖面图",
|
||||
["btn.color"] = "上色",
|
||||
["btn.colorOn"] = "取消上色",
|
||||
|
||||
@@ -51,6 +53,8 @@ internal static class DefaultTexts
|
||||
["kind.hill"] = "Hills",
|
||||
["kind.plateau"] = "Plateau",
|
||||
["kind.plain"] = "Plain",
|
||||
["legend.title"] = "Hypsometric tint",
|
||||
["profile.title"] = "Terrain profile",
|
||||
["btn.color"] = "Colour",
|
||||
["btn.colorOn"] = "No colour",
|
||||
|
||||
|
||||
@@ -112,36 +112,44 @@ public static class TerrainAnalyzer
|
||||
return (a + b - 2 * c) / 1000.0 * 6.0;
|
||||
}
|
||||
|
||||
/// <summary>按海拔给颜色(分层设色,与课本一致:绿→黄→棕→白)。</summary>
|
||||
/// <summary>
|
||||
/// 教科书规范的**分层设色**:按固定高程档位套用固定色阶,档内不渐变。
|
||||
///
|
||||
/// 人教版七年级上册的分层设色色阶(自低到高):
|
||||
/// 深绿 → 浅绿 → 绿 → 浅黄 → 黄 → 浅褐 → 褐 → 浅棕 → 白
|
||||
/// 关键点:**同一档内颜色完全相同**,这样一眼就能数出有几层,
|
||||
/// 而不是课本上那种连续渐变。
|
||||
/// </summary>
|
||||
public static (byte R, byte G, byte B) ColorForHeight(float h, float min, float max)
|
||||
{
|
||||
var t = max - min < 1 ? 0.5 : Math.Clamp((h - min) / (max - min), 0, 1);
|
||||
// 按绝对高程分档(教科书就是这么画的:看的是海拔,不是相对高度)
|
||||
const float band = 200f; // 每 200 米一档
|
||||
|
||||
// 低:深绿 → 草绿 → 黄 → 土黄 → 棕 → 浅棕 → 白
|
||||
var stops = new (double T, byte R, byte G, byte B)[]
|
||||
{
|
||||
(0.00, 46, 110, 72), // 深绿(谷底)
|
||||
(0.30, 96, 158, 84), // 草绿
|
||||
(0.55, 186, 196, 96), // 黄绿
|
||||
(0.72, 214, 178, 108), // 土黄
|
||||
(0.86, 176, 132, 96), // 棕
|
||||
(0.95, 208, 186, 164), // 浅棕
|
||||
(1.00, 245, 245, 245) // 雪白
|
||||
};
|
||||
|
||||
for (var i = 0; i < stops.Length - 1; i++)
|
||||
{
|
||||
var a = stops[i]; var b = stops[i + 1];
|
||||
if (t >= a.T && t <= b.T)
|
||||
{
|
||||
var k = (t - a.T) / Math.Max(1e-6, b.T - a.T);
|
||||
return (Lerp(a.R, b.R, k), Lerp(a.G, b.G, k), Lerp(a.B, b.B, k));
|
||||
}
|
||||
}
|
||||
var last = stops[^1];
|
||||
return (last.R, last.G, last.B);
|
||||
if (h < 200) return (0x1E, 0x6B, 0x3A); // 深绿:< 200 m
|
||||
if (h < 400) return (0x4E, 0x9E, 0x4E); // 浅绿:200–400
|
||||
if (h < 600) return (0xA8, 0xC6, 0x66); // 绿:400–600
|
||||
if (h < 800) return (0xE8, 0xE2, 0x9A); // 浅黄:600–800
|
||||
if (h < 1000) return (0xE0, 0xC0, 0x5A); // 黄:800–1000
|
||||
if (h < 1200) return (0xC8, 0x9A, 0x63); // 浅褐:1000–1200
|
||||
if (h < 1400) return (0xA8, 0x74, 0x4C); // 褐:1200–1400
|
||||
if (h < 1600) return (0xC8, 0xA8, 0x8C); // 浅棕:1400–1600
|
||||
return (0xF5, 0xF5, 0xF0); // 白:> 1600(雪线以上)
|
||||
}
|
||||
|
||||
/// <summary>该颜色属于哪一档(用于图例)。</summary>
|
||||
public static string BandName(float h) => h switch
|
||||
{
|
||||
< 200 => "200 米以下",
|
||||
< 400 => "200–400 米",
|
||||
< 600 => "400–600 米",
|
||||
< 800 => "600–800 米",
|
||||
< 1000 => "800–1000 米",
|
||||
< 1200 => "1000–1200 米",
|
||||
< 1400 => "1200–1400 米",
|
||||
< 1600 => "1400–1600 米",
|
||||
_ => "1600 米以上"
|
||||
};
|
||||
|
||||
private static byte Lerp(byte a, byte b, double k)
|
||||
=> (byte)Math.Clamp(a + (b - a) * k, 0, 255);
|
||||
}
|
||||
@@ -93,6 +93,7 @@ public sealed class TerrainField
|
||||
case TerrainKind.Plateau: BuildPlateau(); break;
|
||||
case TerrainKind.Plain: BuildPlain(); break;
|
||||
}
|
||||
BuildFeatures();
|
||||
}
|
||||
|
||||
private void BuildMountain()
|
||||
@@ -296,6 +297,89 @@ public sealed class TerrainField
|
||||
return TerrainFeature.None;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 河流:从最高点出发,沿最陡下降方向流到图边。
|
||||
/// 教科书上的河流画蓝色线,且**只在河谷(等高线凸向高处的一侧)里流**。
|
||||
/// </summary>
|
||||
public List<(double U, double V)> River { get; } = new();
|
||||
|
||||
/// <summary>山峰位置(用于画 ▲ 与高程数字):局部最高点。</summary>
|
||||
public List<(double U, double V, float Height)> Peaks { get; } = new();
|
||||
|
||||
/// <summary>陡崖位置(用于画锯齿线):坡度极大处。</summary>
|
||||
public List<(double U, double V)> Cliffs { get; } = new();
|
||||
|
||||
/// <summary>找出山峰、陡崖,并生成河流线。</summary>
|
||||
private void BuildFeatures()
|
||||
{
|
||||
// --- 山峰:局部最高且足够高 ---
|
||||
const int step = 4;
|
||||
for (var y = step; y < Size - step; y += step)
|
||||
{
|
||||
for (var x = step; x < Size - step; x += step)
|
||||
{
|
||||
var u = (double)x / (Size - 1);
|
||||
var v = (double)y / (Size - 1);
|
||||
var h = Heights[y, x];
|
||||
if (h < MaxHeight * 0.55) continue;
|
||||
|
||||
var isMax = true;
|
||||
for (var dy = -step; dy <= step && isMax; dy += step)
|
||||
for (var dx = -step; dx <= step; dx += step)
|
||||
{
|
||||
if (dx == 0 && dy == 0) continue;
|
||||
if (Heights[y + dy, x + dx] > h) { isMax = false; break; }
|
||||
}
|
||||
if (isMax) Peaks.Add((u, v, h));
|
||||
}
|
||||
}
|
||||
Peaks.Sort((a, b) => b.Height.CompareTo(a.Height));
|
||||
|
||||
// --- 陡崖:坡度极大 ---
|
||||
const int cstep = 3;
|
||||
for (var y = cstep; y < Size - cstep; y += cstep)
|
||||
{
|
||||
for (var x = cstep; x < Size - cstep; x += cstep)
|
||||
{
|
||||
var u = (double)x / (Size - 1);
|
||||
var v = (double)y / (Size - 1);
|
||||
var h = 0.004;
|
||||
var du = (Heights[y, x + 2] - Heights[y, x - 2]) / (2 * h * (Size - 1)) / 1000;
|
||||
var dv = (Heights[y + 2, x] - Heights[y - 2, x]) / (2 * h * (Size - 1)) / 1000;
|
||||
var slope = Math.Sqrt(du * du + dv * dv);
|
||||
if (slope > 0.11) Cliffs.Add((u, v));
|
||||
}
|
||||
}
|
||||
|
||||
// --- 河流:从最高点沿最陡下降方向走 ---
|
||||
if (Peaks.Count > 0)
|
||||
{
|
||||
var start = Peaks[0];
|
||||
var cu = start.U; var cv = start.V;
|
||||
River.Add((cu, cv));
|
||||
const int maxSteps = 400;
|
||||
for (var step2 = 0; step2 < maxSteps; step2++)
|
||||
{
|
||||
var h0 = SampleSmooth(cu, cv);
|
||||
double bestU = 0, bestV = 0; var bestH = h0; var found = false;
|
||||
for (var a = 0; a < 16; a++)
|
||||
{
|
||||
var ang = a * Math.PI * 2 / 16;
|
||||
var nu = cu + Math.Cos(ang) * 0.012;
|
||||
var nv = cv + Math.Sin(ang) * 0.012;
|
||||
if (nu < 0 || nu > 1 || nv < 0 || nv > 1) continue;
|
||||
var nh = SampleSmooth(nu, nv);
|
||||
if (nh < bestH) { bestH = nh; bestU = nu; bestV = nv; found = true; }
|
||||
}
|
||||
if (!found) break;
|
||||
cu = bestU; cv = bestV;
|
||||
River.Add((cu, cv));
|
||||
if (cu <= 0.001 || cu >= 0.999 || cv <= 0.001 || cv >= 0.999) break;
|
||||
if (bestH < MinHeight + 20) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>等高线高度列表:从 MaxHeight 往下按等高距取整。</summary>
|
||||
public List<float> ContourLevels()
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
],
|
||||
"dataDir": "earth-geography.model",
|
||||
"version": "1.8",
|
||||
"updatedAt": "2026-11-14T01:56:57Z",
|
||||
"updatedAt": "2026-11-14T02:48:20Z",
|
||||
"chrome": {
|
||||
"titleBar": "#0C1828",
|
||||
"titleBorder": "#1B2740",
|
||||
@@ -26,5 +26,5 @@
|
||||
"button": "#9FB4D4",
|
||||
"frame": "#0A1524"
|
||||
},
|
||||
"build": "def7ac1a55"
|
||||
"build": "ede9f2fdd0"
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
"preview": "preview.png",
|
||||
"apiVersion": 1,
|
||||
"version": "1.6",
|
||||
"updatedAt": "2026-11-14T01:56:57Z",
|
||||
"updatedAt": "2026-11-14T02:48:20Z",
|
||||
"chrome": {
|
||||
"titleBar": "#0C1828",
|
||||
"titleBorder": "#1B2740",
|
||||
@@ -32,5 +32,5 @@
|
||||
"button": "#9FB4D4",
|
||||
"frame": "#0A1524"
|
||||
},
|
||||
"build": "d53a3ed8d0"
|
||||
"build": "bbd2908c17"
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
"preview": "preview.png",
|
||||
"apiVersion": 1,
|
||||
"version": "1.6",
|
||||
"updatedAt": "2026-11-14T01:56:57Z",
|
||||
"updatedAt": "2026-11-14T02:48:20Z",
|
||||
"chrome": {
|
||||
"titleBar": "#0C1828",
|
||||
"titleBorder": "#1B2740",
|
||||
@@ -32,5 +32,5 @@
|
||||
"button": "#9FB4D4",
|
||||
"frame": "#0A1524"
|
||||
},
|
||||
"build": "ea44c4934b"
|
||||
"build": "b54f691efe"
|
||||
}
|
||||
@@ -25,7 +25,7 @@
|
||||
"preview": "preview.png",
|
||||
"apiVersion": 1,
|
||||
"version": "1.5",
|
||||
"updatedAt": "2026-11-14T01:56:57Z",
|
||||
"updatedAt": "2026-11-14T02:48:20Z",
|
||||
"chrome": {
|
||||
"titleBar": "#FFFFFF",
|
||||
"titleBorder": "#E3E8F3",
|
||||
@@ -33,5 +33,5 @@
|
||||
"button": "#5B6A86",
|
||||
"frame": "#F4F6FB"
|
||||
},
|
||||
"build": "c6d584422f"
|
||||
"build": "f95a08e72a"
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 58 KiB |
+13
-13
@@ -1,32 +1,32 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"generated": "2026-11-14T01:56:57Z",
|
||||
"generated": "2026-11-14T02:48:20Z",
|
||||
"repository": "https://gitcode.com/2509_92447106/GC",
|
||||
"branch": "main",
|
||||
"modelDir": "model",
|
||||
"launcher": {
|
||||
"version": "1.0.6",
|
||||
"revision": "e1d82a059c",
|
||||
"version": "1.0.7",
|
||||
"revision": "79af318215",
|
||||
"packages": {
|
||||
"win-x64": {
|
||||
"path": "dist/GC-win-x64.zip",
|
||||
"url": "https://gitcode.com/2509_92447106/GC/releases/download/v1.0.6/GC-win-x64.zip"
|
||||
"url": "https://gitcode.com/2509_92447106/GC/releases/download/v1.0.7/GC-win-x64.zip"
|
||||
},
|
||||
"win-arm64": {
|
||||
"path": "dist/GC-win-arm64.zip",
|
||||
"url": "https://gitcode.com/2509_92447106/GC/releases/download/v1.0.6/GC-win-arm64.zip"
|
||||
"url": "https://gitcode.com/2509_92447106/GC/releases/download/v1.0.7/GC-win-arm64.zip"
|
||||
},
|
||||
"osx-arm64": {
|
||||
"path": "dist/GC-osx-arm64.zip",
|
||||
"url": "https://gitcode.com/2509_92447106/GC/releases/download/v1.0.6/GC-osx-arm64.zip"
|
||||
"url": "https://gitcode.com/2509_92447106/GC/releases/download/v1.0.7/GC-osx-arm64.zip"
|
||||
},
|
||||
"osx-x64": {
|
||||
"path": "dist/GC-osx-x64.zip",
|
||||
"url": "https://gitcode.com/2509_92447106/GC/releases/download/v1.0.6/GC-osx-x64.zip"
|
||||
"url": "https://gitcode.com/2509_92447106/GC/releases/download/v1.0.7/GC-osx-x64.zip"
|
||||
},
|
||||
"linux-x64": {
|
||||
"path": "dist/GC-linux-x64.zip",
|
||||
"url": "https://gitcode.com/2509_92447106/GC/releases/download/v1.0.6/GC-linux-x64.zip"
|
||||
"url": "https://gitcode.com/2509_92447106/GC/releases/download/v1.0.7/GC-linux-x64.zip"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -34,31 +34,31 @@
|
||||
{
|
||||
"id": "contour-map",
|
||||
"version": "1.0",
|
||||
"build": "2baf95e031",
|
||||
"build": "4d5485eed8",
|
||||
"dir": "model/contour-map"
|
||||
},
|
||||
{
|
||||
"id": "earth-geography",
|
||||
"version": "1.8",
|
||||
"build": "def7ac1a55",
|
||||
"build": "ede9f2fdd0",
|
||||
"dir": "model/earth-geography"
|
||||
},
|
||||
{
|
||||
"id": "earth-revolution",
|
||||
"version": "1.6",
|
||||
"build": "d53a3ed8d0",
|
||||
"build": "bbd2908c17",
|
||||
"dir": "model/earth-revolution"
|
||||
},
|
||||
{
|
||||
"id": "earth-rotation",
|
||||
"version": "1.6",
|
||||
"build": "ea44c4934b",
|
||||
"build": "b54f691efe",
|
||||
"dir": "model/earth-rotation"
|
||||
},
|
||||
{
|
||||
"id": "scale-calculator",
|
||||
"version": "1.5",
|
||||
"build": "c6d584422f",
|
||||
"build": "f95a08e72a",
|
||||
"dir": "model/scale-calculator"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -35,16 +35,22 @@ public partial class App : Application
|
||||
var window = new MainWindow();
|
||||
window.Show();
|
||||
|
||||
// 首帧之后再构造 ViewModel:Post 而非依赖 Opened,
|
||||
// 因为 Opened 在某些情况下不触发(headless / 部分平台),
|
||||
// 会导致 DataContext 一直是 null、主页面白屏。
|
||||
// 扫描模型 / 加载封面在后台线程做,UI 线程只负责赋值,
|
||||
// 这样窗口能立刻响应,不会卡在白屏。
|
||||
MainViewModel vm = null!;
|
||||
window.Opened += (_, _) =>
|
||||
{
|
||||
Avalonia.Threading.Dispatcher.UIThread.Post(() =>
|
||||
Task.Run(() => new MainViewModel(services))
|
||||
.ContinueWith(t =>
|
||||
{
|
||||
vm = new MainViewModel(services);
|
||||
window.DataContext = vm;
|
||||
WireMainViewModel(vm, window, services, desktop);
|
||||
}, Avalonia.Threading.DispatcherPriority.Background);
|
||||
};
|
||||
vm = t.Result;
|
||||
Avalonia.Threading.Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
window.DataContext = vm;
|
||||
WireMainViewModel(vm, window, services, desktop);
|
||||
}, Avalonia.Threading.DispatcherPriority.Background);
|
||||
}, System.Threading.Tasks.TaskScheduler.Default);
|
||||
|
||||
// 应用图标不依赖 ViewModel,先设好让窗口一出现就有图标
|
||||
try
|
||||
|
||||
+13
-13
@@ -1,32 +1,32 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"generated": "2026-11-14T01:56:57Z",
|
||||
"generated": "2026-11-14T02:48:20Z",
|
||||
"repository": "https://gitcode.com/2509_92447106/GC",
|
||||
"branch": "main",
|
||||
"modelDir": "model",
|
||||
"launcher": {
|
||||
"version": "1.0.6",
|
||||
"revision": "e1d82a059c",
|
||||
"version": "1.0.7",
|
||||
"revision": "79af318215",
|
||||
"packages": {
|
||||
"win-x64": {
|
||||
"path": "dist/GC-win-x64.zip",
|
||||
"url": "https://gitcode.com/2509_92447106/GC/releases/download/v1.0.6/GC-win-x64.zip"
|
||||
"url": "https://gitcode.com/2509_92447106/GC/releases/download/v1.0.7/GC-win-x64.zip"
|
||||
},
|
||||
"win-arm64": {
|
||||
"path": "dist/GC-win-arm64.zip",
|
||||
"url": "https://gitcode.com/2509_92447106/GC/releases/download/v1.0.6/GC-win-arm64.zip"
|
||||
"url": "https://gitcode.com/2509_92447106/GC/releases/download/v1.0.7/GC-win-arm64.zip"
|
||||
},
|
||||
"osx-arm64": {
|
||||
"path": "dist/GC-osx-arm64.zip",
|
||||
"url": "https://gitcode.com/2509_92447106/GC/releases/download/v1.0.6/GC-osx-arm64.zip"
|
||||
"url": "https://gitcode.com/2509_92447106/GC/releases/download/v1.0.7/GC-osx-arm64.zip"
|
||||
},
|
||||
"osx-x64": {
|
||||
"path": "dist/GC-osx-x64.zip",
|
||||
"url": "https://gitcode.com/2509_92447106/GC/releases/download/v1.0.6/GC-osx-x64.zip"
|
||||
"url": "https://gitcode.com/2509_92447106/GC/releases/download/v1.0.7/GC-osx-x64.zip"
|
||||
},
|
||||
"linux-x64": {
|
||||
"path": "dist/GC-linux-x64.zip",
|
||||
"url": "https://gitcode.com/2509_92447106/GC/releases/download/v1.0.6/GC-linux-x64.zip"
|
||||
"url": "https://gitcode.com/2509_92447106/GC/releases/download/v1.0.7/GC-linux-x64.zip"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -34,31 +34,31 @@
|
||||
{
|
||||
"id": "contour-map",
|
||||
"version": "1.0",
|
||||
"build": "2baf95e031",
|
||||
"build": "4d5485eed8",
|
||||
"dir": "model/contour-map"
|
||||
},
|
||||
{
|
||||
"id": "earth-geography",
|
||||
"version": "1.8",
|
||||
"build": "def7ac1a55",
|
||||
"build": "ede9f2fdd0",
|
||||
"dir": "model/earth-geography"
|
||||
},
|
||||
{
|
||||
"id": "earth-revolution",
|
||||
"version": "1.6",
|
||||
"build": "d53a3ed8d0",
|
||||
"build": "bbd2908c17",
|
||||
"dir": "model/earth-revolution"
|
||||
},
|
||||
{
|
||||
"id": "earth-rotation",
|
||||
"version": "1.6",
|
||||
"build": "ea44c4934b",
|
||||
"build": "b54f691efe",
|
||||
"dir": "model/earth-rotation"
|
||||
},
|
||||
{
|
||||
"id": "scale-calculator",
|
||||
"version": "1.5",
|
||||
"build": "c6d584422f",
|
||||
"build": "f95a08e72a",
|
||||
"dir": "model/scale-calculator"
|
||||
}
|
||||
]
|
||||
|
||||
Reference in new issue
Block a user