pitopt 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pitopt/__init__.py +15 -0
- pitopt/__main__.py +7 -0
- pitopt/cli.py +207 -0
- pitopt/config.py +530 -0
- pitopt/core/__init__.py +1 -0
- pitopt/core/cancel.py +32 -0
- pitopt/core/design.py +475 -0
- pitopt/core/design_detail/__init__.py +5 -0
- pitopt/core/design_detail/angles.py +100 -0
- pitopt/core/design_detail/builder.py +230 -0
- pitopt/core/design_detail/config.py +416 -0
- pitopt/core/design_detail/footprint.py +199 -0
- pitopt/core/design_detail/offset.py +114 -0
- pitopt/core/design_detail/parameters.py +336 -0
- pitopt/core/design_detail/ramp.py +533 -0
- pitopt/core/design_detail/reconcile.py +210 -0
- pitopt/core/design_detail/stack.py +245 -0
- pitopt/core/design_detail/validate.py +198 -0
- pitopt/core/economics.py +245 -0
- pitopt/core/limits.py +136 -0
- pitopt/core/pitsurface.py +108 -0
- pitopt/core/planning.py +223 -0
- pitopt/core/precedence.py +486 -0
- pitopt/core/reblock.py +272 -0
- pitopt/core/reserves.py +339 -0
- pitopt/core/schedule.py +360 -0
- pitopt/core/sensitivity.py +100 -0
- pitopt/core/shells.py +100 -0
- pitopt/core/solver.py +182 -0
- pitopt/core/verify.py +310 -0
- pitopt/io/__init__.py +3 -0
- pitopt/io/blockmodel.py +210 -0
- pitopt/io/console.py +75 -0
- pitopt/io/datasets.py +204 -0
- pitopt/io/datfile.py +93 -0
- pitopt/io/design_export.py +360 -0
- pitopt/io/dxf.py +259 -0
- pitopt/io/excel.py +231 -0
- pitopt/io/pdf.py +376 -0
- pitopt/io/plot.py +66 -0
- pitopt/io/results.py +594 -0
- pitopt/io/viz.py +371 -0
- pitopt/mcp_server.py +632 -0
- pitopt/pipeline.py +1022 -0
- pitopt/provenance.py +62 -0
- pitopt/ui/__init__.py +3 -0
- pitopt/ui/design_service.py +412 -0
- pitopt/ui/mcp_controller.py +509 -0
- pitopt/ui/onboard.py +403 -0
- pitopt/ui/server.py +1145 -0
- pitopt/ui/staging.py +49 -0
- pitopt/ui/static/css/app.css +301 -0
- pitopt/ui/static/css/chat.css +657 -0
- pitopt/ui/static/css/design.css +62 -0
- pitopt/ui/static/fonts/IBMPlexMono-400.woff2 +0 -0
- pitopt/ui/static/fonts/IBMPlexMono-500.woff2 +0 -0
- pitopt/ui/static/fonts/IBMPlexMono-600.woff2 +0 -0
- pitopt/ui/static/fonts/IBMPlexSans-var.woff2 +0 -0
- pitopt/ui/static/fonts/OFL.txt +93 -0
- pitopt/ui/static/i18n/en.json +1229 -0
- pitopt/ui/static/img/design.webp +0 -0
- pitopt/ui/static/img/og-pitopt-2026-11.png +0 -0
- pitopt/ui/static/img/pitbypit.webp +0 -0
- pitopt/ui/static/img/pushback.webp +0 -0
- pitopt/ui/static/img/summary.webp +0 -0
- pitopt/ui/static/img/tutorial-marvin.webp +0 -0
- pitopt/ui/static/index.html +24 -0
- pitopt/ui/static/js/actions.js +4 -0
- pitopt/ui/static/js/app.js +223 -0
- pitopt/ui/static/js/charts.js +279 -0
- pitopt/ui/static/js/chat-panel.js +1210 -0
- pitopt/ui/static/js/commands.js +1025 -0
- pitopt/ui/static/js/csp-boot.js +48 -0
- pitopt/ui/static/js/design/core.js +194 -0
- pitopt/ui/static/js/design/plan.js +105 -0
- pitopt/ui/static/js/design/planview.js +49 -0
- pitopt/ui/static/js/design/section.js +80 -0
- pitopt/ui/static/js/design/three.js +45 -0
- pitopt/ui/static/js/design/ui.js +175 -0
- pitopt/ui/static/js/i18n.js +205 -0
- pitopt/ui/static/js/manage.js +119 -0
- pitopt/ui/static/js/modal.js +16 -0
- pitopt/ui/static/js/run.js +81 -0
- pitopt/ui/static/js/store.js +103 -0
- pitopt/ui/static/js/tutorial-guide.js +140 -0
- pitopt/ui/static/js/util.js +98 -0
- pitopt/ui/static/js/views/blocks.js +106 -0
- pitopt/ui/static/js/views/common.js +37 -0
- pitopt/ui/static/js/views/design_ekspor.js +69 -0
- pitopt/ui/static/js/views/design_generate.js +76 -0
- pitopt/ui/static/js/views/design_penampang.js +72 -0
- pitopt/ui/static/js/views/design_ramp.js +109 -0
- pitopt/ui/static/js/views/design_sektor.js +117 -0
- pitopt/ui/static/js/views/design_sumber.js +75 -0
- pitopt/ui/static/js/views/design_validasi.js +88 -0
- pitopt/ui/static/js/views/misc.js +128 -0
- pitopt/ui/static/js/views/params.js +189 -0
- pitopt/ui/static/js/views/pitbypit.js +65 -0
- pitopt/ui/static/js/views/plan.js +140 -0
- pitopt/ui/static/js/views/summary.js +94 -0
- pitopt/ui/static/js/views/upload.js +503 -0
- pitopt/ui/static/js/views/view3d.js +85 -0
- pitopt/ui/static/js/views/workspace.js +103 -0
- pitopt/ui/static/landing.html +487 -0
- pitopt-1.1.0.dist-info/METADATA +180 -0
- pitopt-1.1.0.dist-info/RECORD +112 -0
- pitopt-1.1.0.dist-info/WHEEL +5 -0
- pitopt-1.1.0.dist-info/entry_points.txt +3 -0
- pitopt-1.1.0.dist-info/licenses/LICENSE +661 -0
- pitopt-1.1.0.dist-info/licenses/NOTICE +19 -0
- pitopt-1.1.0.dist-info/licenses/THIRD_PARTY_NOTICES.md +52 -0
- pitopt-1.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright (c) 2026 Orebit (Ghozian Islam Karami)
|
|
3
|
+
// Synchronous CSP bootstrapper for optional single-host AI Chat.
|
|
4
|
+
// Runs before module scripts so baseline connect-src 'self' is always enforced
|
|
5
|
+
// unless the user explicitly enabled and approved one HTTPS or loopback origin.
|
|
6
|
+
(function () {
|
|
7
|
+
"use strict";
|
|
8
|
+
|
|
9
|
+
var BASE_CSP =
|
|
10
|
+
"default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; " +
|
|
11
|
+
"img-src 'self' data: blob:; font-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'";
|
|
12
|
+
|
|
13
|
+
var origin = null;
|
|
14
|
+
try {
|
|
15
|
+
if (localStorage.getItem("pitopt.aiChat.enabled.v1") === "1") {
|
|
16
|
+
var raw = String(localStorage.getItem("pitopt.aiChat.cspOrigin.v1") || "").trim();
|
|
17
|
+
if (raw && !/[\s;,*'"\\]/.test(raw)) {
|
|
18
|
+
var u = new URL(raw);
|
|
19
|
+
var isHttps = u.protocol === "https:";
|
|
20
|
+
var isLoopback = u.protocol === "http:" && (u.hostname === "127.0.0.1" || u.hostname === "localhost");
|
|
21
|
+
if (!u.username && !u.password && u.origin && u.origin !== "null" && u.origin === raw && (isHttps || isLoopback)) {
|
|
22
|
+
origin = u.origin;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
} catch (e) {
|
|
27
|
+
origin = null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
Object.defineProperty(window, "__PITOPT_CSP_CHAT_ORIGIN__", {
|
|
32
|
+
value: origin,
|
|
33
|
+
writable: false,
|
|
34
|
+
configurable: false,
|
|
35
|
+
enumerable: true,
|
|
36
|
+
});
|
|
37
|
+
} catch (e) {
|
|
38
|
+
window.__PITOPT_CSP_CHAT_ORIGIN__ = origin;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
var csp = origin
|
|
42
|
+
? BASE_CSP.replace(/(\bconnect-src\s+[^;]*)/, function (m) { return m + " " + origin; })
|
|
43
|
+
: BASE_CSP;
|
|
44
|
+
var meta = document.createElement("meta");
|
|
45
|
+
meta.httpEquiv = "Content-Security-Policy";
|
|
46
|
+
meta.content = csp;
|
|
47
|
+
document.head.appendChild(meta);
|
|
48
|
+
})();
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright (c) 2026 Orebit (Ghozian Islam Karami)
|
|
3
|
+
// Detailed design (Desain Detail): the state every one of its screens shares, and the calls that fill it.
|
|
4
|
+
//
|
|
5
|
+
// One design is held per scenario. Parameter edits are a draft sent with each Generate; they never touch the
|
|
6
|
+
// scenario's file, and "Simpan sebagai skenario" writes them to a new one like any other PitOpt parameter change.
|
|
7
|
+
import { S, notify } from "../store.js";
|
|
8
|
+
import { api, toast } from "../util.js";
|
|
9
|
+
|
|
10
|
+
const fresh = () => ({
|
|
11
|
+
state: null, block: null, topo: null, err: null, loading: true, draft: {}, job: null, live: [], result: null, notice: null,
|
|
12
|
+
rl: null, plan: null, planBusy: false, section: null, line: null, layers: { shell: true, bench: true, ramp: true, sector: true, blocks: true },
|
|
13
|
+
color: null, ve: 2, sel: 0, tab: "param", exported: null, supportPrompt: false, baseline: null,
|
|
14
|
+
});
|
|
15
|
+
export const D = { key: "", selectionVersion: -1, ...fresh() };
|
|
16
|
+
let generation = 0;
|
|
17
|
+
const tickets = {};
|
|
18
|
+
const context = (kind) => ({kind, generation, selection: S.selectionVersion, key: D.key, ticket: tickets[kind] = (tickets[kind] || 0) + 1});
|
|
19
|
+
const current = (owner) => owner.generation === generation && owner.selection === S.selectionVersion
|
|
20
|
+
&& owner.key === D.key && owner.ticket === tickets[owner.kind];
|
|
21
|
+
|
|
22
|
+
const post = (path, body) => api(path, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ project: S.project, scenario: S.scenario, ...body }) });
|
|
23
|
+
const get = (path, q = {}) => api(`${path}?${new URLSearchParams({ project: S.project, scenario: S.scenario, ...q })}`);
|
|
24
|
+
|
|
25
|
+
/** Called by every design screen's render: reset and load when the scenario changed. */
|
|
26
|
+
export function ensure() {
|
|
27
|
+
const key = `${S.project}/${S.scenario}`;
|
|
28
|
+
if (D.key === key && D.selectionVersion === S.selectionVersion) return;
|
|
29
|
+
generation++; D.selectionVersion = S.selectionVersion;
|
|
30
|
+
D.key = key;
|
|
31
|
+
Object.assign(D, fresh());
|
|
32
|
+
const owner = context("ensure");
|
|
33
|
+
loadState().then(async () => {
|
|
34
|
+
if (!current(owner)) return;
|
|
35
|
+
if (!D.state?.has_results || !D.state.blocks_ready) return;
|
|
36
|
+
await Promise.all([loadBlock(), loadPlan(null)]);
|
|
37
|
+
if (current(owner) && D.state?.session) await loadResult();
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function loadBlock() {
|
|
42
|
+
const owner = context("block");
|
|
43
|
+
try { const block = await get("/api/design/blocks"); if (!current(owner)) return; D.block = block; } catch (e) { if (!current(owner)) return; D.block = null; D.notice = e.message; }
|
|
44
|
+
notify();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function loadState() {
|
|
48
|
+
const owner = context("state");
|
|
49
|
+
try { const state = await post("/api/design/state", { params: D.draft }); if (!current(owner)) return; D.state = state; D.err = null; }
|
|
50
|
+
catch (e) { if (!current(owner)) return; D.state = null; D.err = e.message; }
|
|
51
|
+
D.loading = false;
|
|
52
|
+
if (D.state?.params && !changed()) D.baseline = structuredClone(D.state.params.detail); // the scenario as its file has it
|
|
53
|
+
notify();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function loadResult() {
|
|
57
|
+
const owner = context("result");
|
|
58
|
+
try {
|
|
59
|
+
const result = await get("/api/design/result");
|
|
60
|
+
if (!current(owner)) return;
|
|
61
|
+
D.result = result;
|
|
62
|
+
D.color = D.result.classes.configured ? (D.color || "kelas") : "kadar";
|
|
63
|
+
await loadPlan();
|
|
64
|
+
} catch (e) { if (!current(owner)) return; D.result = null; D.notice = e.message; }
|
|
65
|
+
notify();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function maybePromptForSupport() {
|
|
69
|
+
try {
|
|
70
|
+
if (localStorage.getItem("pitopt-support-prompted")) return;
|
|
71
|
+
D.supportPrompt = true;
|
|
72
|
+
localStorage.setItem("pitopt-support-prompted", "1");
|
|
73
|
+
} catch { /* storage may be disabled; show it for this session */
|
|
74
|
+
D.supportPrompt = true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export async function loadPlan(rl = D.rl) {
|
|
79
|
+
const owner = context("plan");
|
|
80
|
+
D.planBusy = true;
|
|
81
|
+
try {
|
|
82
|
+
const plan = await get("/api/design/plan", rl === null ? {} : { rl });
|
|
83
|
+
if (!current(owner)) return;
|
|
84
|
+
D.plan = plan;
|
|
85
|
+
D.rl = D.plan.rl;
|
|
86
|
+
D.color ||= D.plan.classes.configured ? "kelas" : "kadar"; // classes come from the project's own configuration
|
|
87
|
+
} catch (e) { if (!current(owner)) return; D.plan = null; D.notice = e.message; }
|
|
88
|
+
D.planBusy = false;
|
|
89
|
+
notify();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// ── parameters ──
|
|
93
|
+
export const base = () => D.state?.params?.detail;
|
|
94
|
+
export function value(path) {
|
|
95
|
+
if (path in D.draft) return D.draft[path];
|
|
96
|
+
return path.split(".").reduce((o, k) => (o == null ? undefined : o[k]), base());
|
|
97
|
+
}
|
|
98
|
+
export function setParam(path, val) {
|
|
99
|
+
const original = path.split(".").reduce((o, k) => (o == null ? undefined : o[k]), D.baseline);
|
|
100
|
+
if (JSON.stringify(val) === JSON.stringify(original)) delete D.draft[path]; else D.draft[path] = val;
|
|
101
|
+
loadState();
|
|
102
|
+
}
|
|
103
|
+
export function resetDraft() { D.draft = {}; return loadState(); }
|
|
104
|
+
export const changed = () => Object.keys(D.draft).length > 0;
|
|
105
|
+
/** Where a parameter came from: the project's own record, or "changed here" for an edit not yet saved. */
|
|
106
|
+
export function provenance(path) {
|
|
107
|
+
if (path in D.draft) return { source: "asumsi", note: "diubah di layar ini, belum disimpan" };
|
|
108
|
+
const p = D.state?.provenance || {};
|
|
109
|
+
return p[`design.detail.${path}`] || p[`design.${path}`] || { source: "default" };
|
|
110
|
+
}
|
|
111
|
+
export const badge = (path) => {
|
|
112
|
+
const { source, note, ref } = provenance(path);
|
|
113
|
+
const known = ["dokumen", "asumsi", "default"].includes(source) ? source : "default";
|
|
114
|
+
const label = { dokumen: "DOKUMEN", asumsi: "ASUMSI", default: "DEFAULT" }[known];
|
|
115
|
+
const title = String(ref || note || "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", "\"": """, "'": "'" })[c]);
|
|
116
|
+
return `<span class="badge ${known}" title="${title}">${label}</span>`;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// ── generate / cancel ──
|
|
120
|
+
let polling = false;
|
|
121
|
+
export async function generate() {
|
|
122
|
+
if (D.job?.status === "running") return;
|
|
123
|
+
const owner = context("generate");
|
|
124
|
+
D.live = []; D.notice = null;
|
|
125
|
+
try {
|
|
126
|
+
const { job } = await post("/api/design/run", { params: D.draft });
|
|
127
|
+
if (!current(owner)) return;
|
|
128
|
+
D.job = { id: job, status: "running", fraction: 0, next: 0, elapsed: 0, total: null, done: 0 };
|
|
129
|
+
D.tab = "param";
|
|
130
|
+
notify();
|
|
131
|
+
poll();
|
|
132
|
+
} catch (e) { if (!current(owner)) return; D.notice = e.message; D.job = null; notify(); }
|
|
133
|
+
}
|
|
134
|
+
export async function cancelGenerate() {
|
|
135
|
+
if (D.job?.status !== "running") return;
|
|
136
|
+
try { await post("/api/design/cancel", { id: D.job.id }); } catch (e) { toast(e.message); }
|
|
137
|
+
}
|
|
138
|
+
async function poll() {
|
|
139
|
+
if (polling) return;
|
|
140
|
+
polling = true;
|
|
141
|
+
const owner = context("poll");
|
|
142
|
+
try {
|
|
143
|
+
while (D.job && D.job.status === "running") {
|
|
144
|
+
const id = D.job.id;
|
|
145
|
+
const snap = await get("/api/design/job", { id, since: D.job.next });
|
|
146
|
+
if (!current(owner) || !D.job || D.job.id !== id) return;
|
|
147
|
+
for (const e of snap.events) if (e.type === "bench_done") { D.live.push(e); D.job.total = e.total; D.job.done = e.done; }
|
|
148
|
+
D.job = { ...D.job, status: snap.status, fraction: snap.fraction, next: snap.next, elapsed: snap.elapsed, error: snap.error };
|
|
149
|
+
notify();
|
|
150
|
+
if (snap.status !== "running") break;
|
|
151
|
+
await new Promise((r) => setTimeout(r, 200));
|
|
152
|
+
}
|
|
153
|
+
if (!current(owner)) return;
|
|
154
|
+
const status = D.job?.status;
|
|
155
|
+
if (status === "done") { maybePromptForSupport(); await loadResult(); await loadState(); toast("Desain selesai."); }
|
|
156
|
+
else if (status === "cancelled") toast("Generate dibatalkan — desain sebelumnya tetap ditampilkan.");
|
|
157
|
+
else if (status === "error") D.notice = D.job.error;
|
|
158
|
+
D.live = [];
|
|
159
|
+
} catch (e) { if (current(owner)) D.notice = e.message; }
|
|
160
|
+
finally { polling = false; if (!current(owner) && D.job?.status === "running") poll(); }
|
|
161
|
+
if (current(owner)) notify();
|
|
162
|
+
}
|
|
163
|
+
export const running = () => D.job?.status === "running";
|
|
164
|
+
/** The benches to draw: the ones streamed in while computing, else the finished design. */
|
|
165
|
+
export const benches = () => (running() ? D.live : D.result?.benches || []);
|
|
166
|
+
|
|
167
|
+
export async function exportFiles(kinds) {
|
|
168
|
+
const owner = context("export");
|
|
169
|
+
try {
|
|
170
|
+
const response = await post("/api/design/export", { kinds });
|
|
171
|
+
if (!current(owner)) return;
|
|
172
|
+
D.exported = response.files;
|
|
173
|
+
toast(`${D.exported.length} file ditulis ke folder hasil.`);
|
|
174
|
+
}
|
|
175
|
+
catch (e) { if (!current(owner)) return; D.notice = e.message; }
|
|
176
|
+
notify();
|
|
177
|
+
}
|
|
178
|
+
export async function loadSection(p1, p2) {
|
|
179
|
+
const owner = context("section");
|
|
180
|
+
D.line = { p1, p2 };
|
|
181
|
+
try {
|
|
182
|
+
const q = { x1: p1[0], y1: p1[1], x2: p2[0], y2: p2[1] };
|
|
183
|
+
const [section, topo] = await Promise.all([get("/api/design/section", q), get("/api/section", { ...q, layers: "" }).catch(() => null)]);
|
|
184
|
+
if (!current(owner)) return;
|
|
185
|
+
D.section = section; D.topo = topo; D.notice = null;
|
|
186
|
+
}
|
|
187
|
+
catch (e) { if (!current(owner)) return; D.section = null; D.notice = e.message; }
|
|
188
|
+
notify();
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// ── shared bits ──
|
|
192
|
+
export const STATUS = { OK: ["ok", "OK"], PERINGATAN: ["peringatan", "PERINGATAN"], BLOKIR: ["blokir", "BLOKIR"] };
|
|
193
|
+
export const pill = (status) => `<span class="tagc ${(STATUS[status] || STATUS.OK)[0]}">${(STATUS[status] || STATUS.OK)[1]}</span>`;
|
|
194
|
+
export const worst = (list) => list.reduce((w, s) => (["OK", "PERINGATAN", "BLOKIR"].indexOf(s) > ["OK", "PERINGATAN", "BLOKIR"].indexOf(w) ? s : w), "OK");
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright (c) 2026 Orebit (Ghozian Islam Karami)
|
|
3
|
+
// The plan view: honest scale (one metre is the same number of pixels both ways), blocks at their real size,
|
|
4
|
+
// outlines, the road and the sector lines. Blocks are drawn one path per colour, not one element per cell, so a
|
|
5
|
+
// bench of tens of thousands of blocks stays fast.
|
|
6
|
+
import { viridis } from "../util.js";
|
|
7
|
+
import { lang } from "../i18n.js";
|
|
8
|
+
|
|
9
|
+
// Sequential purples for grade classes, light to dark; the first (waste) is a neutral. Dark mode keeps the order.
|
|
10
|
+
const CLASS = {
|
|
11
|
+
light: ["#E7E3D8", "#D9D3EF", "#A99BD8", "#6C4FB8", "#3E2A86", "#241A5E"],
|
|
12
|
+
dark: ["#3A3D3A", "#4A4570", "#6F62B0", "#9A86E0", "#C0B0FF", "#E0D8FF"],
|
|
13
|
+
};
|
|
14
|
+
export const dark = () => document.documentElement.dataset.theme === "dark";
|
|
15
|
+
export const classColour = (i) => (dark() ? CLASS.dark : CLASS.light)[Math.min(Math.max(i, 0), 5)];
|
|
16
|
+
|
|
17
|
+
/** The colour of a block under the chosen mode; `range` is [min, max] of the plotted variable. */
|
|
18
|
+
export function blockColour(plan, i, mode, range) {
|
|
19
|
+
if (mode === "kelas" && plan.classes.configured) return classColour(plan.cls[i]);
|
|
20
|
+
const v = mode === "nilai" ? plan.value[i] : plan.grade[i];
|
|
21
|
+
if (mode !== "nilai" && v < 0) return classColour(0);
|
|
22
|
+
const [lo, hi] = range;
|
|
23
|
+
return viridis(hi > lo ? (v - lo) / (hi - lo) : 0.5);
|
|
24
|
+
}
|
|
25
|
+
export function rangeOf(plan, mode) {
|
|
26
|
+
const v = (mode === "nilai" ? plan.value : plan.grade).filter((x) => x >= 0 || mode === "nilai");
|
|
27
|
+
return v.length ? [Math.min(...v), Math.max(...v)] : [0, 1];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export class View {
|
|
31
|
+
constructor(canvas, bounds, pad = 34) {
|
|
32
|
+
const dpr = window.devicePixelRatio || 1;
|
|
33
|
+
const w = canvas.clientWidth || canvas.width, h = canvas.clientHeight || canvas.height;
|
|
34
|
+
canvas.width = Math.round(w * dpr); canvas.height = Math.round(h * dpr);
|
|
35
|
+
this.ctx = canvas.getContext("2d");
|
|
36
|
+
this.ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
37
|
+
this.w = w; this.h = h;
|
|
38
|
+
const [x0, y0, x1, y1] = bounds;
|
|
39
|
+
this.s = Math.min((w - 2 * pad) / (x1 - x0 || 1), (h - 2 * pad) / (y1 - y0 || 1));
|
|
40
|
+
this.ox = pad + ((w - 2 * pad) - this.s * (x1 - x0)) / 2 - this.s * x0;
|
|
41
|
+
this.oy = h - pad - ((h - 2 * pad) - this.s * (y1 - y0)) / 2 + this.s * y0;
|
|
42
|
+
this.bounds = bounds;
|
|
43
|
+
}
|
|
44
|
+
X(x) { return this.ox + this.s * x; }
|
|
45
|
+
Y(y) { return this.oy - this.s * y; }
|
|
46
|
+
world(px, py) { return [(px - this.ox) / this.s, (this.oy - py) / this.s]; }
|
|
47
|
+
clear(bg) { this.ctx.fillStyle = bg; this.ctx.fillRect(0, 0, this.w, this.h); }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function boundsOf(polys, margin = 0.06) {
|
|
51
|
+
let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
|
|
52
|
+
for (const p of polys) for (const [x, y] of p.o) { x0 = Math.min(x0, x); x1 = Math.max(x1, x); y0 = Math.min(y0, y); y1 = Math.max(y1, y); }
|
|
53
|
+
const mx = (x1 - x0) * margin, my = (y1 - y0) * margin;
|
|
54
|
+
return [x0 - mx, y0 - my, x1 + mx, y1 + my];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function tracePoly(v, polys) {
|
|
58
|
+
const c = v.ctx; c.beginPath();
|
|
59
|
+
for (const p of polys) for (const ring of [p.o, ...p.h]) {
|
|
60
|
+
ring.forEach(([x, y], i) => (i ? c.lineTo(v.X(x), v.Y(y)) : c.moveTo(v.X(x), v.Y(y))));
|
|
61
|
+
c.closePath();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export function stroke(v, polys, { color, width = 1.4, dash = [] }) {
|
|
65
|
+
const c = v.ctx; tracePoly(v, polys); c.strokeStyle = color; c.lineWidth = width; c.setLineDash(dash); c.stroke(); c.setLineDash([]);
|
|
66
|
+
}
|
|
67
|
+
export function line(v, pts, { color, width = 2, dash = [] }) {
|
|
68
|
+
const c = v.ctx; c.beginPath(); pts.forEach(([x, y], i) => (i ? c.lineTo(v.X(x), v.Y(y)) : c.moveTo(v.X(x), v.Y(y))));
|
|
69
|
+
c.strokeStyle = color; c.lineWidth = width; c.setLineDash(dash); c.stroke(); c.setLineDash([]);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Blocks as filled squares of their true size; `faded[i]` draws a block half-transparent. */
|
|
73
|
+
export function drawBlocks(v, plan, colours, faded) {
|
|
74
|
+
const c = v.ctx, hx = (plan.dx * v.s) / 2, hy = (plan.dy * v.s) / 2;
|
|
75
|
+
for (const alpha of [1, 0.32]) {
|
|
76
|
+
const byColour = new Map();
|
|
77
|
+
for (let i = 0; i < plan.x.length; i++) {
|
|
78
|
+
if ((faded[i] ? 0.32 : 1) !== alpha) continue;
|
|
79
|
+
(byColour.get(colours[i]) || byColour.set(colours[i], new Path2D()).get(colours[i])).rect(v.X(plan.x[i]) - hx, v.Y(plan.y[i]) - hy, 2 * hx, 2 * hy);
|
|
80
|
+
}
|
|
81
|
+
c.globalAlpha = alpha;
|
|
82
|
+
for (const [colour, path] of byColour) { c.fillStyle = colour; c.fill(path); }
|
|
83
|
+
}
|
|
84
|
+
c.globalAlpha = 1;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const nice = (m) => { const e = 10 ** Math.floor(Math.log10(m)); const f = m / e; return (f < 1.5 ? 1 : f < 3.5 ? 2 : f < 7.5 ? 5 : 10) * e; };
|
|
88
|
+
export function scaleBar(v, colour) {
|
|
89
|
+
const len = nice(v.w * 0.16 / v.s), c = v.ctx, x = 16, y = v.h - 16;
|
|
90
|
+
c.strokeStyle = c.fillStyle = colour; c.lineWidth = 2; c.beginPath(); c.moveTo(x, y); c.lineTo(x + len * v.s, y); c.stroke();
|
|
91
|
+
c.font = "11px 'IBM Plex Mono', monospace"; c.fillText(`${len} m`, x, y - 6);
|
|
92
|
+
}
|
|
93
|
+
export function north(v, colour) {
|
|
94
|
+
const c = v.ctx, x = v.w - 22, y = 30;
|
|
95
|
+
c.fillStyle = c.strokeStyle = colour; c.beginPath(); c.moveTo(x, y - 14); c.lineTo(x - 6, y + 4); c.lineTo(x + 6, y + 4); c.closePath(); c.fill();
|
|
96
|
+
c.font = "600 11px 'IBM Plex Sans', sans-serif"; c.textAlign = "center"; c.fillText(lang === "en" ? "N" : "U", x, y + 18); c.textAlign = "left";
|
|
97
|
+
}
|
|
98
|
+
export function axes(v, colour) {
|
|
99
|
+
const c = v.ctx, [x0, y0, x1, y1] = v.bounds, step = nice(80 / v.s);
|
|
100
|
+
c.fillStyle = colour; c.font = "10px 'IBM Plex Mono', monospace"; c.globalAlpha = 0.75;
|
|
101
|
+
for (let x = Math.ceil(x0 / step) * step; x < x1; x += step) c.fillText(Math.round(x), v.X(x) - 14, v.h - 4);
|
|
102
|
+
for (let y = Math.ceil(y0 / step) * step; y < y1; y += step) c.fillText(Math.round(y), 2, v.Y(y) + 3);
|
|
103
|
+
c.globalAlpha = 1;
|
|
104
|
+
}
|
|
105
|
+
export const css = (name) => getComputedStyle(document.documentElement).getPropertyValue(name).trim();
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright (c) 2026 Orebit (Ghozian Islam Karami)
|
|
3
|
+
// The plan view every design screen paints: the block slice, the shell and the design outline, the road and the
|
|
4
|
+
// sector lines. Everything is drawn from the plan and result the server sent; nothing is recomputed here.
|
|
5
|
+
import { D } from "./core.js";
|
|
6
|
+
import { View, axes, blockColour, boundsOf, classColour, css, dark, drawBlocks, line, north, rangeOf, scaleBar, stroke, tracePoly } from "./plan.js";
|
|
7
|
+
|
|
8
|
+
function wedge(centre, r, from, to) {
|
|
9
|
+
const span = ((to - from) % 360 + 360) % 360 || 360, pts = [centre];
|
|
10
|
+
for (let a = 0; a <= 48; a++) { const az = ((from + (span * a) / 48) * Math.PI) / 180; pts.push([centre[0] + r * Math.sin(az), centre[1] + r * Math.cos(az)]); }
|
|
11
|
+
return { o: pts, h: [] };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** opts: plan, result?, layers, mode, sel (sector index), sectors (state.sectors), extra(view) for screen-specific overlays */
|
|
15
|
+
export function paintPlan(canvas, opts) {
|
|
16
|
+
const { plan, result, layers = {}, mode = "kelas", sel = null, sectors = [], showDesign = true, showRamp = true } = opts;
|
|
17
|
+
const outline = [...plan.shell, ...(showDesign ? plan.design : []), ...(result?.benches?.length ? result.benches[0].crest : [])];
|
|
18
|
+
const v = new View(canvas, boundsOf(outline.length ? outline : [{ o: [[plan.x[0] - 50, plan.y[0] - 50], [plan.x[0] + 50, plan.y[0] + 50]] }]));
|
|
19
|
+
v.clear(css("--panel2") || "#F7F8FA");
|
|
20
|
+
const range = rangeOf(plan, mode);
|
|
21
|
+
if (layers.blocks !== false) {
|
|
22
|
+
const colours = plan.x.map((_, i) => blockColour(plan, i, mode, range));
|
|
23
|
+
const inside = (i) => plan.in_shell[i] || plan.in_design[i];
|
|
24
|
+
drawBlocks(v, plan, colours, plan.x.map((_, i) => !inside(i)));
|
|
25
|
+
}
|
|
26
|
+
const ink = css("--text"), accent = css("--accent"), pit = css("--pit");
|
|
27
|
+
if (sel !== null && sectors[sel] && result) {
|
|
28
|
+
const s = sectors[sel];
|
|
29
|
+
const rmax = Math.max(...result.benches[0].crest.flatMap((p) => p.o.map(([x, y]) => Math.hypot(x - result.centre[0], y - result.centre[1])))) * 1.05;
|
|
30
|
+
tracePoly(v, [wedge(result.centre, rmax, s.azimuth_from, s.azimuth_to)]);
|
|
31
|
+
v.ctx.fillStyle = dark() ? "rgba(127,163,232,.18)" : "rgba(43,76,140,.12)"; v.ctx.fill();
|
|
32
|
+
}
|
|
33
|
+
if (layers.shell !== false) {
|
|
34
|
+
stroke(v, plan.shell, { color: dark() ? "rgba(0,0,0,.55)" : "rgba(255,255,255,.85)", width: 3.4 }); // halo: legible over any block colour
|
|
35
|
+
stroke(v, plan.shell, { color: ink, width: 1.4, dash: [6, 4] });
|
|
36
|
+
}
|
|
37
|
+
if (showDesign && plan.design.length) stroke(v, plan.design, { color: accent, width: 2.2 });
|
|
38
|
+
if (result && layers.sector !== false && (result.sector_lines || []).length > 1) {
|
|
39
|
+
for (const s of result.sector_lines) line(v, [result.centre, s.to], { color: pit, width: 1, dash: [2, 4] });
|
|
40
|
+
}
|
|
41
|
+
if (result?.ramp && showRamp && layers.ramp !== false) {
|
|
42
|
+
if (result.ramp.edges) for (const e of [result.ramp.edges.left, result.ramp.edges.right]) line(v, e, { color: accent, width: 0.8 });
|
|
43
|
+
line(v, result.ramp.x.map((x, i) => [x, result.ramp.y[i]]), { color: accent, width: 2.6 });
|
|
44
|
+
}
|
|
45
|
+
axes(v, ink); scaleBar(v, ink); north(v, ink);
|
|
46
|
+
opts.extra?.(v);
|
|
47
|
+
return v;
|
|
48
|
+
}
|
|
49
|
+
export const centreOf = () => D.result?.centre;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright (c) 2026 Orebit (Ghozian Islam Karami)
|
|
3
|
+
// A vertical section along a line: the designed wall (bench and berm), the optimiser shell's stair, a strip of the
|
|
4
|
+
// block model one cell thick, the ground, and where the road crosses. Drawn at any vertical exaggeration; the scale
|
|
5
|
+
// is written on the drawing itself, so a picture taken from it can never be read as 1:1 when it is not.
|
|
6
|
+
import { fmt } from "../util.js";
|
|
7
|
+
import { t } from "../i18n.js";
|
|
8
|
+
import { blockColour, classColour, css, rangeOf } from "./plan.js";
|
|
9
|
+
|
|
10
|
+
const norm = (a) => ((a % 360) + 360) % 360;
|
|
11
|
+
const bearing = (from, to) => norm((Math.atan2(to[0] - from[0], to[1] - from[1]) * 180) / Math.PI);
|
|
12
|
+
const sectorAt = (sectors, az) => sectors.find((s) => ((az - s.azimuth_from + 360) % 360) < (((s.azimuth_to - s.azimuth_from) % 360 + 360) % 360 || 360))?.name || "";
|
|
13
|
+
|
|
14
|
+
export function drawSection(canvas, sec, topo, { ve, mode, sectors, centre, p1, p2, width }) {
|
|
15
|
+
const padL = 50, padR = 14, padT = 34, padB = 30;
|
|
16
|
+
const rls = sec.rings.map((r) => r.rl);
|
|
17
|
+
const zmin = Math.min(...rls) - sec.dz, zmax = Math.max(...rls) + sec.dz * 2;
|
|
18
|
+
const s = (width - padL - padR) / sec.length;
|
|
19
|
+
const h = Math.round(padT + padB + (zmax - zmin) * s * ve);
|
|
20
|
+
canvas.style.width = `${width}px`; canvas.style.height = `${h}px`;
|
|
21
|
+
const dpr = window.devicePixelRatio || 1;
|
|
22
|
+
canvas.width = width * dpr; canvas.height = h * dpr;
|
|
23
|
+
const c = canvas.getContext("2d"); c.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
24
|
+
const X = (d) => padL + d * s, Y = (z) => h - padB - (z - zmin) * s * ve;
|
|
25
|
+
const ink = css("--text"), muted = css("--muted"), accent = css("--accent");
|
|
26
|
+
c.fillStyle = css("--panel2"); c.fillRect(0, 0, width, h);
|
|
27
|
+
|
|
28
|
+
// block strip, faded where the design has already mined it
|
|
29
|
+
const b = sec.blocks, range = rangeOf({ grade: b.grade, value: b.grade, cls: b.cls, classes: sec.classes }, mode);
|
|
30
|
+
const cell = sec.cell, hw = (cell * s) / 2, hh = (sec.dz * s * ve) / 2;
|
|
31
|
+
for (const alpha of [1, 0.3]) {
|
|
32
|
+
c.globalAlpha = alpha;
|
|
33
|
+
b.d.forEach((d, i) => {
|
|
34
|
+
if ((b.mined[i] ? 0.3 : 1) !== alpha) return;
|
|
35
|
+
const colour = mode === "kelas" && sec.classes.configured ? classColour(b.cls[i]) : blockColour({ ...b, classes: sec.classes, value: b.grade }, i, "kadar", range);
|
|
36
|
+
c.fillStyle = colour; c.fillRect(X(d) - hw, Y(b.rl[i]) - hh, 2 * hw, 2 * hh);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
c.globalAlpha = 1;
|
|
40
|
+
|
|
41
|
+
// ground
|
|
42
|
+
if (topo?.series?.topo) {
|
|
43
|
+
c.beginPath(); let pen = false;
|
|
44
|
+
topo.distance.forEach((d, i) => { const z = topo.series.topo[i]; if (z == null) { pen = false; return; } (pen ? c.lineTo : c.moveTo).call(c, X(d), Y(z)); pen = true; });
|
|
45
|
+
c.strokeStyle = css("--topo"); c.lineWidth = 2; c.stroke();
|
|
46
|
+
}
|
|
47
|
+
// the optimiser shell as a stair
|
|
48
|
+
const edge = (pick) => sec.shell.filter((l) => l.spans.length).sort((a, b2) => a.rl - b2.rl).flatMap((l) => { const d = pick(l.spans); return [[d, l.rl - sec.dz / 2], [d, l.rl + sec.dz / 2]]; });
|
|
49
|
+
const left = edge((sp) => Math.min(...sp.map((x) => x[0]))), right = edge((sp) => Math.max(...sp.map((x) => x[1])));
|
|
50
|
+
if (left.length) {
|
|
51
|
+
c.setLineDash([6, 4]); c.strokeStyle = ink; c.lineWidth = 1.3; c.beginPath();
|
|
52
|
+
[...left, ...right.slice().reverse()].forEach(([d, z], i) => (i ? c.lineTo(X(d), Y(z)) : c.moveTo(X(d), Y(z)))); c.stroke(); c.setLineDash([]);
|
|
53
|
+
}
|
|
54
|
+
// the designed wall: every ring, lowest first, crest before toe at the same elevation so berms read as flats
|
|
55
|
+
const rings = sec.rings.filter((r) => r.spans.length).sort((a, b2) => a.rl - b2.rl || (a.kind === "crest" ? -1 : 1));
|
|
56
|
+
const wall = (pick) => rings.map((r) => [pick(r.spans), r.rl]);
|
|
57
|
+
const lw = wall((sp) => Math.min(...sp.map((x) => x[0]))), rw = wall((sp) => Math.max(...sp.map((x) => x[1])));
|
|
58
|
+
c.strokeStyle = css("--pit"); c.lineWidth = 2.2; c.beginPath();
|
|
59
|
+
[...lw, ...rw.slice().reverse()].forEach(([d, z], i) => (i ? c.lineTo(X(d), Y(z)) : c.moveTo(X(d), Y(z)))); c.stroke();
|
|
60
|
+
// the road
|
|
61
|
+
c.font = "10px 'IBM Plex Mono', monospace";
|
|
62
|
+
for (const r of sec.ramp) {
|
|
63
|
+
c.fillStyle = accent; c.fillRect(X(r.d) - width * 0.02, Y(r.rl) - 2, width * 0.04, 4);
|
|
64
|
+
c.fillText(`ramp +${fmt(r.rl, 0)}`, X(r.d) - width * 0.02, Y(r.rl) - 6);
|
|
65
|
+
}
|
|
66
|
+
// axes and the scale, written on the drawing
|
|
67
|
+
c.fillStyle = muted; c.strokeStyle = css("--line2"); c.lineWidth = 1;
|
|
68
|
+
const step = Math.max(10, Math.round(((zmax - zmin) / 6) / 10) * 10);
|
|
69
|
+
for (let z = Math.ceil(zmin / step) * step; z < zmax; z += step) { c.beginPath(); c.moveTo(padL, Y(z)); c.lineTo(width - padR, Y(z)); c.stroke(); c.fillText(`+${fmt(z, 0)}`, 4, Y(z) + 3); }
|
|
70
|
+
const dstep = Math.round(sec.length / 6 / 50) * 50 || 50;
|
|
71
|
+
for (let d = 0; d <= sec.length; d += dstep) c.fillText(fmt(d, 0), X(d) - 8, h - padB + 14);
|
|
72
|
+
c.fillText(t("jarak sepanjang A–A′ (m)"), padL, h - 6);
|
|
73
|
+
const a = sectorAt(sectors, norm(bearing(centre, p1))), z = sectorAt(sectors, norm(bearing(centre, p2)));
|
|
74
|
+
c.fillStyle = ink; c.font = "600 11px 'IBM Plex Sans', sans-serif";
|
|
75
|
+
c.fillText(`A ${a} ${fmt(bearing(centre, p1), 0)}°`, padL + 4, 14); const secEnd = `${z} ${fmt(bearing(centre, p2), 0)}° A′`; c.fillText(secEnd, width - padR - c.measureText(secEnd).width - 4, 14);
|
|
76
|
+
const badge = ve === 1 ? `1:1 · VE ${fmt(1, 1)}×` : `VE ${fmt(ve, 1)}×`, bw = c.measureText(badge).width + 16;
|
|
77
|
+
const bx = padL + (width - padL - padR - bw) / 2;
|
|
78
|
+
c.fillStyle = ve === 1 ? css("--good") : ink; c.fillRect(bx, 4, bw, 20);
|
|
79
|
+
c.fillStyle = css("--bg"); c.fillText(badge, bx + 8, 18);
|
|
80
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright (c) 2026 Orebit (Ghozian Islam Karami)
|
|
3
|
+
// The oblique 3D view of the design (Plotly): benches drawn as they arrive, the road, the shell, the sector lines.
|
|
4
|
+
// The vertical exaggeration is applied to the scene's aspect ratio and always shown, so the exaggerated wall is
|
|
5
|
+
// never mistaken for the real one.
|
|
6
|
+
import { D, benches } from "./core.js";
|
|
7
|
+
import { css, dark } from "./plan.js";
|
|
8
|
+
import { t } from "../i18n.js";
|
|
9
|
+
|
|
10
|
+
let plotly = null;
|
|
11
|
+
const load = () => window.Plotly ? Promise.resolve(window.Plotly) : (plotly ||= new Promise((ok, no) => {
|
|
12
|
+
const s = document.createElement("script"); s.src = "/static/vendor/plotly.min.js";
|
|
13
|
+
s.onload = () => ok(window.Plotly); s.onerror = () => no(new Error(t("Plotly gagal dimuat"))); document.head.appendChild(s);
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
const rings = (polys, z, out) => { for (const p of polys) for (const ring of [p.o, ...p.h]) { for (const [x, y] of ring) { out.x.push(x); out.y.push(y); out.z.push(z); } out.x.push(ring[0][0], null); out.y.push(ring[0][1], null); out.z.push(z, null); } };
|
|
17
|
+
|
|
18
|
+
export async function draw(el) {
|
|
19
|
+
const Plotly = await load();
|
|
20
|
+
const list = benches(), R = D.result, pit = css("--pit"), accent = css("--accent"), ink = css("--text");
|
|
21
|
+
const crest = { x: [], y: [], z: [] }, toe = { x: [], y: [], z: [] }, shell = { x: [], y: [], z: [] };
|
|
22
|
+
for (const b of list) { rings(b.crest, b.crest_rl, crest); rings(b.toe, b.toe_rl, toe); }
|
|
23
|
+
if (D.layers.shell && R) for (const l of R.shell) rings(l.polys, l.rl, shell);
|
|
24
|
+
const traces = [];
|
|
25
|
+
if (D.layers.shell && shell.x.length) traces.push({ type: "scatter3d", mode: "lines", ...shell, line: { color: ink, width: 2, dash: "dash" }, name: t("Shell PitOpt"), hoverinfo: "skip", opacity: 0.55 });
|
|
26
|
+
if (D.layers.bench) {
|
|
27
|
+
traces.push({ type: "scatter3d", mode: "lines", ...crest, line: { color: pit, width: 3 }, name: "Crest", hoverinfo: "skip" });
|
|
28
|
+
traces.push({ type: "scatter3d", mode: "lines", ...toe, line: { color: dark() ? "#8A6A3B" : "#C9A97A", width: 2 }, name: "Toe", hoverinfo: "skip" });
|
|
29
|
+
}
|
|
30
|
+
if (D.layers.ramp && R?.ramp && !(D.job?.status === "running")) traces.push({ type: "scatter3d", mode: "lines", x: R.ramp.x, y: R.ramp.y, z: R.ramp.z, line: { color: accent, width: 7 }, name: t("Ramp centerline"), hovertemplate: "RL %{z:.1f} m<extra></extra>" });
|
|
31
|
+
if (D.layers.sector && R?.sector_lines?.length > 1) {
|
|
32
|
+
const top = R.benches[0]?.crest_rl ?? 0, s = { x: [], y: [], z: [] };
|
|
33
|
+
for (const l of R.sector_lines) { s.x.push(R.centre[0], l.to[0], null); s.y.push(R.centre[1], l.to[1], null); s.z.push(top, top, null); }
|
|
34
|
+
traces.push({ type: "scatter3d", mode: "lines", ...s, line: { color: accent, width: 2, dash: "dot" }, name: t("Sektor"), hoverinfo: "skip" });
|
|
35
|
+
}
|
|
36
|
+
const all = [...crest.x, ...toe.x].filter((v) => v !== null), ally = [...crest.y, ...toe.y].filter((v) => v !== null), allz = [...crest.z, ...toe.z].filter((v) => v !== null);
|
|
37
|
+
const dx = Math.max(...all) - Math.min(...all) || 1, dy = Math.max(...ally) - Math.min(...ally) || 1, dz = Math.max(...allz) - Math.min(...allz) || 1;
|
|
38
|
+
const m = Math.max(dx, dy);
|
|
39
|
+
const bg = css("--panel");
|
|
40
|
+
await Plotly.react(el, traces, {
|
|
41
|
+
margin: { l: 0, r: 0, t: 0, b: 0 }, paper_bgcolor: bg, showlegend: false,
|
|
42
|
+
scene: { aspectmode: "manual", aspectratio: { x: dx / m, y: dy / m, z: (dz / m) * D.ve }, camera: { eye: { x: 1.3, y: -1.5, z: 0.9 } },
|
|
43
|
+
xaxis: { visible: false }, yaxis: { visible: false }, zaxis: { title: "RL (m)", color: css("--muted"), gridcolor: css("--line2") }, bgcolor: bg },
|
|
44
|
+
}, { displayModeBar: false, responsive: true });
|
|
45
|
+
}
|