Compare commits

..

3 Commits

Author SHA1 Message Date
xin
8b50c126b9 feat: 航线 Y 偏移 1/2 幅宽、推荐帧率/曝光时间计算、速度默认值调整
- 第一条航线 Y 坐标偏移 1/2 幅宽,不再紧贴绘制区域边缘
- 生成航线时自动计算推荐帧率和曝光时间(Pika L 900像元 / Pika NIR 320像元)
- 推荐帧率×曝光时间=999,Pika L 最大帧率限制 250fps
- 生成航线后自动填入子任务帧率和曝光时间
- Y 轴定位速度默认 10cm/s,X 扫描 3cm/s,X 回起点 10cm/s
2026-06-25 16:30:21 +08:00
xin
24eaae8219 feat: scan canvas scanConfig support, aspect ratio fix, param panel layout
- 画布支持 scanConfig 坐标范围,修改 X/Y 范围后画布随之更新
- 修复 Y 轴标签位数超过 3 位时溢出画布边框
- 画布按扫描区域宽高比等比例显示
- 相机参数改为纵向排列,画布占比提升至 85%
2026-06-25 15:45:28 +08:00
xin
f75768805b feat: add device-type background colors to subtasks, fix collapsed header height
子任务现按设备类型显示不同背景色和左侧色条,便于区分。
修复 Naive UI default padding-top 导致折叠时标题高度不一致的问题。
2026-06-22 10:30:27 +08:00
17 changed files with 252 additions and 60 deletions

16
CLAUDE.md Normal file
View File

@ -0,0 +1,16 @@
# Spectral Insight Mission Plan
## 版本管理
每次 `git commit` 时需要同时更新版本号和 update.md:
1. **更新版本号**:Cargo.toml、tauri.conf.json、package.json 中 PATCH+1
2. **更新 update.md**:在文件头部插入新版本条目
3. **变更内容由模型根据实际改动总结**,需注明需求来源(如某人提出)
### update.md 格式
```
## vX.Y.Z (YYYY-MM-DD)
- 改动描述(致谢)
```

View File

@ -1,7 +1,7 @@
{ {
"name": "happa-mission-plan", "name": "happa-mission-plan",
"private": true, "private": true,
"version": "0.0.7", "version": "0.0.10",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",

2
src-tauri/Cargo.lock generated
View File

@ -3180,7 +3180,7 @@ dependencies = [
[[package]] [[package]]
name = "spectral-insight-mission-plan" name = "spectral-insight-mission-plan"
version = "0.0.5" version = "0.0.9"
dependencies = [ dependencies = [
"byteorder", "byteorder",
"chrono", "chrono",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "spectral-insight-mission-plan" name = "spectral-insight-mission-plan"
version = "0.0.7" version = "0.0.10"
description = "Spectral Insight Mission Plan" description = "Spectral Insight Mission Plan"
authors = ["you"] authors = ["you"]
edition = "2021" edition = "2021"

View File

@ -4,6 +4,7 @@ use crate::error::AppError;
use crate::io; use crate::io;
use crate::models::{PathLineFile, ScanParams, ScanRegion, CameraParams, ScanMode}; use crate::models::{PathLineFile, ScanParams, ScanRegion, CameraParams, ScanMode};
use crate::services; use crate::services;
use crate::services::camera_recommender::RecommendedCameraParams;
#[command] #[command]
pub fn load_path_line(path: String) -> Result<PathLineFile, AppError> { pub fn load_path_line(path: String) -> Result<PathLineFile, AppError> {
@ -63,3 +64,15 @@ pub fn estimate_scan_time_multi_minutes(
speed_y_cm_s, speed_x_start_cm_s, speed_x_scan_cm_s, &mode, speed_y_cm_s, speed_x_start_cm_s, speed_x_scan_cm_s, &mode,
) )
} }
#[command]
pub fn recommend_hyperspectral_params(
device_type: String,
height_cm: f64,
fov_degrees: f64,
scan_speed_cm_s: f64,
) -> RecommendedCameraParams {
services::camera_recommender::recommend_hyperspectral_params(
&device_type, height_cm, fov_degrees, scan_speed_cm_s,
)
}

View File

@ -40,6 +40,7 @@ pub fn run() {
commands::path_commands::estimate_scan_time_minutes, commands::path_commands::estimate_scan_time_minutes,
commands::path_commands::generate_scan_paths_multi, commands::path_commands::generate_scan_paths_multi,
commands::path_commands::estimate_scan_time_multi_minutes, commands::path_commands::estimate_scan_time_multi_minutes,
commands::path_commands::recommend_hyperspectral_params,
commands::devtools_commands::toggle_devtools, commands::devtools_commands::toggle_devtools,
commands::defaults_commands::save_default_scan_config, commands::defaults_commands::save_default_scan_config,
commands::defaults_commands::load_default_scan_config, commands::defaults_commands::load_default_scan_config,

View File

@ -68,9 +68,9 @@ impl Default for PlannerDefaults {
fov_degrees: 30.0, fov_degrees: 30.0,
height_cm: 50.0, height_cm: 50.0,
coverage_rate: 30.0, coverage_rate: 30.0,
speed_y_cm_s: 5.0, speed_y_cm_s: 10.0,
speed_x_start_cm_s: 20.0, speed_x_start_cm_s: 10.0,
speed_x_scan_cm_s: 10.0, speed_x_scan_cm_s: 3.0,
mode: "OneWay".to_string(), mode: "OneWay".to_string(),
} }
} }

View File

@ -0,0 +1,54 @@
use serde::Serialize;
use super::path_generator::calc_footprint;
#[derive(Debug, Clone, Serialize)]
pub struct RecommendedCameraParams {
#[serde(rename = "recommendedFrameRate")]
pub recommended_frame_rate: u32,
#[serde(rename = "recommendedExposureTime")]
pub recommended_exposure_time: u32,
}
/// Calculate recommended frame rate and maximum exposure time for hyperspectral cameras.
///
/// Formula:
/// across-track pixel size = footprint / num_pixels
/// along-track pixel size = scan_speed / frame_rate
/// Square pixels: footprint / num_pixels = scan_speed / frame_rate
/// => frame_rate = scan_speed * num_pixels / footprint
/// => exposure_time = 999 / frame_rate
///
/// Device limits:
/// Pika L max frame rate = 250 fps
pub fn recommend_hyperspectral_params(
device_type: &str,
height_cm: f64,
fov_degrees: f64,
scan_speed_cm_s: f64,
) -> RecommendedCameraParams {
let (num_pixels, max_fps) = match device_type {
"HyperSpectual400_1000nm" => (900.0, 250), // Pika L
"HyperSpectual1000_1700nm" => (320.0, u32::MAX), // Pika NIR
_ => return RecommendedCameraParams {
recommended_frame_rate: 0,
recommended_exposure_time: 0,
},
};
if scan_speed_cm_s <= 0.0 || height_cm <= 0.0 || fov_degrees <= 0.0 {
return RecommendedCameraParams {
recommended_frame_rate: 0,
recommended_exposure_time: 0,
};
}
let footprint = calc_footprint(height_cm, fov_degrees);
let frame_rate = ((scan_speed_cm_s * num_pixels / footprint).round() as u32).max(1).min(max_fps);
let exposure_time = 999 / frame_rate;
RecommendedCameraParams {
recommended_frame_rate: frame_rate,
recommended_exposure_time: exposure_time,
}
}

View File

@ -1,3 +1,4 @@
pub mod scheduler; pub mod scheduler;
pub mod validator; pub mod validator;
pub mod camera_recommender;
pub mod path_generator; pub mod path_generator;

View File

@ -18,10 +18,15 @@ pub fn generate_path(params: &ScanParams) -> Vec<PathLineRecord> {
let y_min = params.region.y_min; let y_min = params.region.y_min;
let y_max = params.region.y_max; let y_max = params.region.y_max;
let line_count = if step <= 0.0 { let half_fp = footprint / 2.0;
let y_start = y_min + half_fp;
let y_end = y_max - half_fp;
let single_line = step <= 0.0 || y_end <= y_start;
let line_count = if single_line {
1 1
} else { } else {
((y_max - y_min) / step).ceil() as u64 + 1 ((y_end - y_start) / step).ceil() as u64 + 1
}; };
let mut records = Vec::with_capacity(line_count as usize); let mut records = Vec::with_capacity(line_count as usize);
@ -29,8 +34,12 @@ pub fn generate_path(params: &ScanParams) -> Vec<PathLineRecord> {
match params.mode { match params.mode {
ScanMode::Zigzag => { ScanMode::Zigzag => {
for i in 0..line_count { for i in 0..line_count {
let y = y_min + (i as f64) * step; let y = if single_line {
if y > y_max { (y_min + y_max) / 2.0
} else {
y_start + (i as f64) * step
};
if !single_line && y > y_end {
break; break;
} }
@ -53,8 +62,12 @@ pub fn generate_path(params: &ScanParams) -> Vec<PathLineRecord> {
} }
ScanMode::OneWay => { ScanMode::OneWay => {
for i in 0..line_count { for i in 0..line_count {
let y = y_min + (i as f64) * step; let y = if single_line {
if y > y_max { (y_min + y_max) / 2.0
} else {
y_start + (i as f64) * step
};
if !single_line && y > y_end {
break; break;
} }
@ -117,13 +130,26 @@ pub fn generate_paths_multi(
let mut all_records = Vec::new(); let mut all_records = Vec::new();
for (i, region) in regions.iter().enumerate() { for (i, region) in regions.iter().enumerate() {
let is_circle = shapes.get(i).map(|s| s == "Circle").unwrap_or(false); let is_circle = shapes.get(i).map(|s| s == "Circle").unwrap_or(false);
let step = calc_footprint(camera.height_cm, camera.fov_degrees) let footprint = calc_footprint(camera.height_cm, camera.fov_degrees);
* (1.0 - coverage_rate / 100.0); let step = footprint * (1.0 - coverage_rate / 100.0);
let line_count = if step <= 0.0 { 1 } else { ((region.y_max - region.y_min) / step).ceil() as u64 + 1 }; let half_fp = footprint / 2.0;
let y_start = region.y_min + half_fp;
let y_end = region.y_max - half_fp;
let single_line = step <= 0.0 || y_end <= y_start;
let line_count = if single_line {
1
} else {
((y_end - y_start) / step).ceil() as u64 + 1
};
for li in 0..line_count { for li in 0..line_count {
let y = region.y_min + (li as f64) * step; let y = if single_line {
if y > region.y_max { break; } (region.y_min + region.y_max) / 2.0
} else {
y_start + (li as f64) * step
};
if !single_line && y > y_end { break; }
let (x_start, x_end) = if is_circle { let (x_start, x_end) = if is_circle {
let cx = (region.x_min + region.x_max) / 2.0; let cx = (region.x_min + region.x_max) / 2.0;

View File

@ -1,7 +1,7 @@
{ {
"$schema": "https://schema.tauri.app/config/2", "$schema": "https://schema.tauri.app/config/2",
"productName": "Spectral Insight Mission Plan", "productName": "Spectral Insight Mission Plan",
"version": "0.0.7", "version": "0.0.10",
"identifier": "com.spectral-insight.mission-plan", "identifier": "com.spectral-insight.mission-plan",
"build": { "build": {
"beforeDevCommand": "npm run dev", "beforeDevCommand": "npm run dev",

View File

@ -11,10 +11,11 @@ import { ref, onMounted, watch } from 'vue';
import type { ScanRegion, ScanMode, ScanShape } from '../../types/path-plan'; import type { ScanRegion, ScanMode, ScanShape } from '../../types/path-plan';
import type { PathLineRecord } from '../../types/path-line'; import type { PathLineRecord } from '../../types/path-line';
const props = defineProps<{ const props = withDefaults(defineProps<{
records: PathLineRecord[]; mode: ScanMode; backgroundImage?: string; records: PathLineRecord[]; mode: ScanMode; backgroundImage?: string;
drawingMode: boolean; drawingShape?: ScanShape; selectedIndex?: number; drawingMode: boolean; drawingShape?: ScanShape; selectedIndex?: number;
}>(); xMin?: number; xMax?: number; yMin?: number; yMax?: number;
}>(), { xMin: 0, xMax: 100, yMin: 0, yMax: 100 });
const regions = defineModel<ScanRegion[]>('regions', { required: true }); const regions = defineModel<ScanRegion[]>('regions', { required: true });
const emit = defineEmits<{ 'add-region': [region: ScanRegion]; 'select-region': [index: number]; 'deselect': [] }>(); const emit = defineEmits<{ 'add-region': [region: ScanRegion]; 'select-region': [index: number]; 'deselect': [] }>();
@ -23,13 +24,13 @@ const isDrawing = ref(false); const isDragging = ref(false); const isResizing =
const resizeCorner = ref(''); const dragTarget = ref(-1); const resizeCorner = ref(''); const dragTarget = ref(-1);
const dragStart = ref({ x: 0, y: 0 }); const regionStart = ref<ScanRegion | null>(null); const dragStart = ref({ x: 0, y: 0 }); const regionStart = ref<ScanRegion | null>(null);
const drawingRect = ref<ScanRegion | null>(null); const bgImage = ref<HTMLImageElement | null>(null); const drawingRect = ref<ScanRegion | null>(null); const bgImage = ref<HTMLImageElement | null>(null);
const padding = 40; let padding = 40;
const COLORS = ['#2080f0', '#f0a020', '#18a058', '#d03050', '#a060e0', '#e06080']; const COLORS = ['#2080f0', '#f0a020', '#18a058', '#d03050', '#a060e0', '#e06080'];
function gs() { const r = canvasContainer.value?.getBoundingClientRect(); return { w: r?.width || 600, h: r?.height || 400 }; } function gs() { const r = canvasContainer.value?.getBoundingClientRect(); return { w: r?.width || 600, h: r?.height || 400 }; }
function tc(cx: number, cy: number) { const r = canvas.value!.getBoundingClientRect(); return { x: cx - r.left, y: cy - r.top }; } function tc(cx: number, cy: number) { const r = canvas.value!.getBoundingClientRect(); return { x: cx - r.left, y: cy - r.top }; }
function tw(cx: number, cy: number) { const { w, h } = gs(); const dw = w - padding * 2, dh = h - padding * 2; return { x: Math.max(0, Math.min(100, (cx - padding) / dw * 100)), y: Math.max(0, Math.min(100, 100 - (cy - padding) / dh * 100)) }; } function tw(cx: number, cy: number) { const { w, h } = gs(); const dw = w - padding * 2, dh = h - padding * 2, rx = props.xMax - props.xMin, ry = props.yMax - props.yMin; const da = rx / ry, ca = dw / dh, drawW = da > ca ? dw : dh * da, drawH = da > ca ? dw / da : dh, offX = da > ca ? 0 : (dw - drawW) / 2, offY = da > ca ? (dh - drawH) / 2 : 0; return { x: Math.max(props.xMin, Math.min(props.xMax, props.xMin + (cx - padding - offX) / drawW * rx)), y: Math.max(props.yMin, Math.min(props.yMax, props.yMax - (cy - padding - offY) / drawH * ry)) }; }
function w2c(wx: number, wy: number) { const { w, h } = gs(); const dw = w - padding * 2, dh = h - padding * 2; return { x: padding + (wx / 100) * dw, y: padding + ((100 - wy) / 100) * dh }; } function w2c(wx: number, wy: number) { const { w, h } = gs(); const dw = w - padding * 2, dh = h - padding * 2, rx = props.xMax - props.xMin, ry = props.yMax - props.yMin; const da = rx / ry, ca = dw / dh, drawW = da > ca ? dw : dh * da, drawH = da > ca ? dw / da : dh, offX = da > ca ? 0 : (dw - drawW) / 2, offY = da > ca ? (dh - drawH) / 2 : 0; return { x: padding + offX + ((wx - props.xMin) / rx) * drawW, y: padding + offY + ((props.yMax - wy) / ry) * drawH }; }
function findR(p: { x: number; y: number }): number { const r = regions.value; for (let i = r.length - 1; i >= 0; i--) { if (p.x >= r[i].xMin && p.x <= r[i].xMax && p.y >= r[i].yMin && p.y <= r[i].yMax) return i; } return -1; } function findR(p: { x: number; y: number }): number { const r = regions.value; for (let i = r.length - 1; i >= 0; i--) { if (p.x >= r[i].xMin && p.x <= r[i].xMax && p.y >= r[i].yMin && p.y <= r[i].yMax) return i; } return -1; }
function findC(p: { x: number; y: number }): { i: number; c: string } | null { const th = 3; for (let i = 0; i < regions.value.length; i++) { const r = regions.value[i]; for (const [c, cx, cy] of [['tl', r.xMin, r.yMax] as const, ['tr', r.xMax, r.yMax] as const, ['bl', r.xMin, r.yMin] as const, ['br', r.xMax, r.yMin] as const]) { if (Math.abs(p.x - cx) < th && Math.abs(p.y - cy) < th) return { i, c }; } } return null; } function findC(p: { x: number; y: number }): { i: number; c: string } | null { const th = 3; for (let i = 0; i < regions.value.length; i++) { const r = regions.value[i]; for (const [c, cx, cy] of [['tl', r.xMin, r.yMax] as const, ['tr', r.xMax, r.yMax] as const, ['bl', r.xMin, r.yMin] as const, ['br', r.xMax, r.yMin] as const]) { if (Math.abs(p.x - cx) < th && Math.abs(p.y - cy) < th) return { i, c }; } } return null; }
@ -45,22 +46,31 @@ function draw() {
canvas.value!.style.width = w + 'px'; canvas.value!.style.height = h + 'px'; canvas.value!.style.width = w + 'px'; canvas.value!.style.height = h + 'px';
ctx.scale(dpr, dpr); ctx.fillStyle = '#f8f8f8'; ctx.fillRect(0, 0, w, h); ctx.scale(dpr, dpr); ctx.fillStyle = '#f8f8f8'; ctx.fillRect(0, 0, w, h);
if (bgImage.value) { ctx.globalAlpha = 0.5; ctx.drawImage(bgImage.value, 0, 0, w, h); ctx.globalAlpha = 1.0; } if (bgImage.value) { ctx.globalAlpha = 0.5; ctx.drawImage(bgImage.value, 0, 0, w, h); ctx.globalAlpha = 1.0; }
ctx.font = '10px sans-serif';
const maxYLabel = Math.max(
ctx.measureText(props.yMin.toFixed(1)).width,
ctx.measureText(props.yMax.toFixed(1)).width
);
padding = Math.max(40, Math.ceil(24 + 4 + maxYLabel + 4 + 16 + 2));
const dw = w - padding * 2, dh = h - padding * 2, ax = 16; const dw = w - padding * 2, dh = h - padding * 2, ax = 16;
const rx = props.xMax - props.xMin, ry = props.yMax - props.yMin;
const da = rx / ry, ca = dw / dh;
const drawW = da > ca ? dw : dh * da, drawH = da > ca ? dw / da : dh;
const offX = da > ca ? 0 : (dw - drawW) / 2, offY = da > ca ? (dh - drawH) / 2 : 0;
ctx.strokeStyle = '#e8e8e8'; ctx.lineWidth = 1; ctx.strokeStyle = '#e8e8e8'; ctx.lineWidth = 1;
for (let i = 0; i <= 10; i++) { const x = padding + (i / 10) * dw; ctx.beginPath(); ctx.moveTo(x, padding); ctx.lineTo(x, padding + dh); ctx.stroke(); } for (let i = 0; i <= 10; i++) { const x = padding + offX + (i / 10) * drawW; ctx.beginPath(); ctx.moveTo(x, padding + offY); ctx.lineTo(x, padding + offY + drawH); ctx.stroke(); }
for (let i = 0; i <= 10; i++) { const y = padding + (i / 10) * dh; ctx.beginPath(); ctx.moveTo(padding, y); ctx.lineTo(padding + dw, y); ctx.stroke(); } for (let i = 0; i <= 10; i++) { const y = padding + offY + (i / 10) * drawH; ctx.beginPath(); ctx.moveTo(padding + offX, y); ctx.lineTo(padding + offX + drawW, y); ctx.stroke(); }
ctx.strokeStyle = '#666'; ctx.lineWidth = 1.5; ctx.strokeStyle = '#666'; ctx.lineWidth = 1.5;
ctx.beginPath(); ctx.moveTo(padding - ax, padding + dh); ctx.lineTo(padding + dw + ax, padding + dh); ctx.stroke(); ctx.beginPath(); ctx.moveTo(padding + offX - ax, padding + offY + drawH); ctx.lineTo(padding + offX + drawW + ax, padding + offY + drawH); ctx.stroke();
ctx.beginPath(); ctx.moveTo(padding, padding + dh + ax); ctx.lineTo(padding, padding - ax); ctx.stroke(); ctx.beginPath(); ctx.moveTo(padding + offX, padding + offY + drawH + ax); ctx.lineTo(padding + offX, padding + offY - ax); ctx.stroke();
ctx.fillStyle = '#888'; ctx.font = '10px sans-serif'; ctx.textAlign = 'center'; ctx.fillStyle = '#888'; ctx.font = '10px sans-serif'; ctx.textAlign = 'center';
for (let i = 0; i <= 10; i++) { const x = padding + (i / 10) * dw; ctx.fillText(String(i * 10), x, padding + dh + ax + 12); ctx.beginPath(); ctx.moveTo(x, padding + dh + ax - 3); ctx.lineTo(x, padding + dh + ax + 3); ctx.stroke(); } for (let i = 0; i <= 10; i++) { const x = padding + offX + (i / 10) * drawW; ctx.fillText((props.xMin + (i / 10) * rx).toFixed(1), x, padding + offY + drawH + ax + 12); ctx.beginPath(); ctx.moveTo(x, padding + offY + drawH + ax - 3); ctx.lineTo(x, padding + offY + drawH + ax + 3); ctx.stroke(); }
ctx.textAlign = 'right'; ctx.textAlign = 'right';
for (let i = 0; i <= 10; i++) { const y = padding + (i / 10) * dh; ctx.fillText(String((10 - i) * 10), padding - ax - 4, y + 4); ctx.beginPath(); ctx.moveTo(padding - ax - 3, y); ctx.lineTo(padding - ax + 3, y); ctx.stroke(); } for (let i = 0; i <= 10; i++) { const y = padding + offY + (i / 10) * drawH; ctx.fillText((props.yMin + (1 - i / 10) * ry).toFixed(1), padding + offX - ax - 4, y + 4); ctx.beginPath(); ctx.moveTo(padding + offX - ax - 3, y); ctx.lineTo(padding + offX - ax + 3, y); ctx.stroke(); }
ctx.textAlign = 'start'; ctx.font = '11px sans-serif'; ctx.textAlign = 'start'; ctx.font = '11px sans-serif';
ctx.fillText('X (cm)', padding + dw + ax - 10, padding + dh + ax + 24); ctx.fillText('X (cm)', padding + offX + drawW + ax - 10, padding + offY + drawH + ax + 24);
ctx.save(); ctx.translate(padding - ax - 24, 10); ctx.rotate(-Math.PI / 2); ctx.fillText('Y (cm)', 0, 0); ctx.restore(); ctx.save(); ctx.translate(padding + offX - ax - 24, 10); ctx.rotate(-Math.PI / 2); ctx.fillText('Y (cm)', 0, 0); ctx.restore();
ctx.strokeStyle = '#f0a020'; ctx.lineWidth = 1; ctx.setLineDash([4, 4]); const z1 = w2c(0, 0), z2 = w2c(100, 100); ctx.strokeRect(z1.x, z1.y, z2.x - z1.x, z2.y - z1.y); ctx.setLineDash([]);
for (let i = 0; i < regions.value.length; i++) { for (let i = 0; i < regions.value.length; i++) {
const r = regions.value[i]; const p1 = w2c(r.xMin, r.yMin), p2 = w2c(r.xMax, r.yMax); const r = regions.value[i]; const p1 = w2c(r.xMin, r.yMin), p2 = w2c(r.xMax, r.yMax);
@ -102,8 +112,8 @@ function onMouseDown(e: MouseEvent) {
function onMouseMove(e: MouseEvent) { function onMouseMove(e: MouseEvent) {
const cp = tc(e.clientX, e.clientY); const cp = tc(e.clientX, e.clientY);
if (isDrawing.value && props.drawingMode) { const p1 = tw(dragStart.value.x, dragStart.value.y), p2 = tw(cp.x, cp.y); drawingRect.value = { shape: props.drawingShape || 'Rect', xMin: Math.min(p1.x, p2.x), xMax: Math.max(p1.x, p2.x), yMin: Math.min(p1.y, p2.y), yMax: Math.max(p1.y, p2.y) }; draw(); return; } if (isDrawing.value && props.drawingMode) { const p1 = tw(dragStart.value.x, dragStart.value.y), p2 = tw(cp.x, cp.y); drawingRect.value = { shape: props.drawingShape || 'Rect', xMin: Math.min(p1.x, p2.x), xMax: Math.max(p1.x, p2.x), yMin: Math.min(p1.y, p2.y), yMax: Math.max(p1.y, p2.y) }; draw(); return; }
if (isDragging.value && dragTarget.value >= 0 && regionStart.value) { const dx = (cp.x - dragStart.value.x) / (gs().w - padding * 2) * 100, dy = -(cp.y - dragStart.value.y) / (gs().h - padding * 2) * 100; const rs = regionStart.value, rw = rs.xMax - rs.xMin, rh = rs.yMax - rs.yMin; const arr = [...regions.value]; arr[dragTarget.value] = { ...arr[dragTarget.value], xMin: Math.max(0, Math.min(100 - rw, rs.xMin + dx)), xMax: Math.max(rs.xMin + dx + 1, Math.min(100, rs.xMax + dx)), yMin: Math.max(0, Math.min(100 - rh, rs.yMin + dy)), yMax: Math.max(rs.yMin + dy + 1, Math.min(100, rs.yMax + dy)) }; regions.value = arr; draw(); return; } if (isDragging.value && dragTarget.value >= 0 && regionStart.value) { const rx = props.xMax - props.xMin, ry = props.yMax - props.yMin; const dw = gs().w - padding * 2, dh = gs().h - padding * 2, da = rx / ry, ca = dw / dh; const drawW = da > ca ? dw : dh * da, drawH = da > ca ? dw / da : dh; const dx = (cp.x - dragStart.value.x) / drawW * rx, dy = -(cp.y - dragStart.value.y) / drawH * ry; const rs = regionStart.value, rw = rs.xMax - rs.xMin, rh = rs.yMax - rs.yMin; const arr = [...regions.value]; arr[dragTarget.value] = { ...arr[dragTarget.value], xMin: Math.max(props.xMin, Math.min(props.xMax - rw, rs.xMin + dx)), xMax: Math.max(rs.xMin + dx + 1, Math.min(props.xMax, rs.xMax + dx)), yMin: Math.max(props.yMin, Math.min(props.yMax - rh, rs.yMin + dy)), yMax: Math.max(rs.yMin + dy + 1, Math.min(props.yMax, rs.yMax + dy)) }; regions.value = arr; draw(); return; }
if (isResizing.value && dragTarget.value >= 0 && regionStart.value) { const p1 = tw(dragStart.value.x, dragStart.value.y), p2 = tw(cp.x, cp.y); const dx = p2.x - p1.x, dy = p2.y - p1.y, rs = regionStart.value; let xMin = rs.xMin, xMax = rs.xMax, yMin = rs.yMin, yMax = rs.yMax; const c = resizeCorner.value; if (c.includes('l')) xMin = Math.min(rs.xMin + dx, rs.xMax - 1); if (c.includes('r')) xMax = Math.max(rs.xMax + dx, rs.xMin + 1); if (c.includes('b')) yMin = Math.min(rs.yMin + dy, rs.yMax - 1); if (c.includes('t')) yMax = Math.max(rs.yMax + dy, rs.yMin + 1); xMin = Math.max(0, xMin); xMax = Math.min(100, xMax); yMin = Math.max(0, yMin); yMax = Math.min(100, yMax); if (xMax - xMin > 1 && yMax - yMin > 1) { const arr = [...regions.value]; arr[dragTarget.value] = { ...arr[dragTarget.value], xMin, xMax, yMin, yMax }; regions.value = arr; draw(); } } if (isResizing.value && dragTarget.value >= 0 && regionStart.value) { const p1 = tw(dragStart.value.x, dragStart.value.y), p2 = tw(cp.x, cp.y); const dx = p2.x - p1.x, dy = p2.y - p1.y, rs = regionStart.value; let xMin = rs.xMin, xMax = rs.xMax, yMin = rs.yMin, yMax = rs.yMax; const c = resizeCorner.value; if (c.includes('l')) xMin = Math.min(rs.xMin + dx, rs.xMax - 1); if (c.includes('r')) xMax = Math.max(rs.xMax + dx, rs.xMin + 1); if (c.includes('b')) yMin = Math.min(rs.yMin + dy, rs.yMax - 1); if (c.includes('t')) yMax = Math.max(rs.yMax + dy, rs.yMin + 1); xMin = Math.max(props.xMin, xMin); xMax = Math.min(props.xMax, xMax); yMin = Math.max(props.yMin, yMin); yMax = Math.min(props.yMax, yMax); if (xMax - xMin > 1 && yMax - yMin > 1) { const arr = [...regions.value]; arr[dragTarget.value] = { ...arr[dragTarget.value], xMin, xMax, yMin, yMax }; regions.value = arr; draw(); } }
} }
function onMouseUp() { function onMouseUp() {
@ -112,7 +122,7 @@ function onMouseUp() {
} }
onMounted(() => { loadBG(props.backgroundImage); window.addEventListener('resize', draw); }); onMounted(() => { loadBG(props.backgroundImage); window.addEventListener('resize', draw); });
watch(() => [regions.value, props.records, props.mode, props.drawingMode, props.drawingShape, props.selectedIndex], () => { draw(); }); watch(() => [regions.value, props.records, props.mode, props.drawingMode, props.drawingShape, props.selectedIndex, props.xMin, props.xMax, props.yMin, props.yMax], () => { draw(); });
watch(() => props.backgroundImage, (v) => { loadBG(v); }); watch(() => props.backgroundImage, (v) => { loadBG(v); });
</script> </script>

View File

@ -2,20 +2,14 @@
<div class="param-panel"> <div class="param-panel">
<n-form size="small" label-placement="top" label-width="auto"> <n-form size="small" label-placement="top" label-width="auto">
<n-card title="相机参数" size="small"> <n-card title="相机参数" size="small">
<n-grid :cols="2" :x-gap="8"> <n-form-item>
<n-gi> <template #label>FOV (°) <HelpIcon helpKey="planner.fov" /></template>
<n-form-item> <n-input-number v-model:value="localCamera.fovDegrees" :min="1" :max="180" />
<template #label>FOV (°) <HelpIcon helpKey="planner.fov" /></template> </n-form-item>
<n-input-number v-model:value="localCamera.fovDegrees" :min="1" :max="180" /> <n-form-item>
</n-form-item> <template #label>高度 (cm) <HelpIcon helpKey="planner.height" /></template>
</n-gi> <n-input-number v-model:value="localCamera.heightCm" :min="1" />
<n-gi> </n-form-item>
<n-form-item>
<template #label>高度 (cm) <HelpIcon helpKey="planner.height" /></template>
<n-input-number v-model:value="localCamera.heightCm" :min="1" />
</n-form-item>
</n-gi>
</n-grid>
<n-form-item> <n-form-item>
<template #label>覆盖率 (%) <HelpIcon helpKey="planner.coverage" /></template> <template #label>覆盖率 (%) <HelpIcon helpKey="planner.coverage" /></template>
<n-slider v-model:value="localCoverageRate" :min="0" :max="100" :step="1" /> <n-slider v-model:value="localCoverageRate" :min="0" :max="100" :step="1" />
@ -55,6 +49,8 @@
<n-descriptions label-placement="left" :column="1"> <n-descriptions label-placement="left" :column="1">
<n-descriptions-item label="扫描线数">{{ lineCount }}</n-descriptions-item> <n-descriptions-item label="扫描线数">{{ lineCount }}</n-descriptions-item>
<n-descriptions-item label="预估耗时">{{ estTimeFormatted }}</n-descriptions-item> <n-descriptions-item label="预估耗时">{{ estTimeFormatted }}</n-descriptions-item>
<n-descriptions-item v-if="recommendedFrameRate && recommendedFrameRate > 0" label="推荐帧率">{{ recommendedFrameRate }} fps</n-descriptions-item>
<n-descriptions-item v-if="recommendedExposureTime && recommendedExposureTime > 0" label="推荐曝光时间">{{ recommendedExposureTime }} ms</n-descriptions-item>
</n-descriptions> </n-descriptions>
</n-card> </n-card>
</n-form> </n-form>
@ -67,7 +63,7 @@ import type { CameraParams, ScanMode } from '../../types/path-plan';
import { formatDuration } from '../../utils/constants'; import { formatDuration } from '../../utils/constants';
import HelpIcon from '../common/HelpIcon.vue'; import HelpIcon from '../common/HelpIcon.vue';
const props = defineProps<{ const props = withDefaults(defineProps<{
camera: CameraParams; camera: CameraParams;
coverageRate: number; coverageRate: number;
speedY: number; speedY: number;
@ -76,7 +72,12 @@ const props = defineProps<{
mode: ScanMode; mode: ScanMode;
lineCount: number; lineCount: number;
estTime: number; estTime: number;
}>(); recommendedFrameRate?: number;
recommendedExposureTime?: number;
}>(), {
recommendedFrameRate: undefined,
recommendedExposureTime: undefined,
});
const emit = defineEmits<{ const emit = defineEmits<{
update: [params: any]; update: [params: any];

View File

@ -33,7 +33,7 @@ export function createDefaultPlannerParams(): PlannerDefaults {
return { return {
fovDegrees: 30, heightCm: 50, fovDegrees: 30, heightCm: 50,
coverageRate: 30, coverageRate: 30,
speedYCmS: 5, speedXStartCmS: 20, speedXScanCmS: 10, speedYCmS: 10, speedXStartCmS: 10, speedXScanCmS: 3,
mode: 'Zigzag', mode: 'Zigzag',
}; };
} }

View File

@ -99,12 +99,13 @@
</n-grid> </n-grid>
</n-form> </n-form>
<n-collapse> <n-collapse class="subtask-collapse">
<n-collapse-item <n-collapse-item
v-for="sub in task.subTasks" v-for="sub in task.subTasks"
:key="sub.id" :key="sub.id"
:title="getSubTaskLabel(sub.type)" :title="getSubTaskLabel(sub.type)"
:name="sub.id" :name="sub.id"
:style="subtaskStyle(sub.type)"
> >
<template #header-extra> <template #header-extra>
<n-button text type="error" size="tiny" @click.stop="handleRemoveSubTask(task.id, sub.id)">删除</n-button> <n-button text type="error" size="tiny" @click.stop="handleRemoveSubTask(task.id, sub.id)">删除</n-button>
@ -218,7 +219,7 @@ import {
import { invoke } from '@tauri-apps/api/core'; import { invoke } from '@tauri-apps/api/core';
import { useMissionStore } from '../stores/mission'; import { useMissionStore } from '../stores/mission';
import { useValidationStore } from '../stores/validation'; import { useValidationStore } from '../stores/validation';
import { SUBTASK_TYPE_LABELS } from '../utils/constants'; import { SUBTASK_TYPE_LABELS, SUBTASK_TYPE_COLORS } from '../utils/constants';
import { formatDuration, formatDateTime } from '../utils/constants'; import { formatDuration, formatDateTime } from '../utils/constants';
import { isHyperspectral, SubTaskType } from '../types/task'; import { isHyperspectral, SubTaskType } from '../types/task';
import type { SubTask } from '../types/task'; import type { SubTask } from '../types/task';
@ -263,6 +264,16 @@ function getSubTaskLabel(type: string): string {
return SUBTASK_TYPE_LABELS[type] || type; return SUBTASK_TYPE_LABELS[type] || type;
} }
function subtaskStyle(type: string) {
const color = SUBTASK_TYPE_COLORS[type] || '#888';
return {
borderLeft: `3px solid ${color}`,
background: `${color}1a`,
borderRadius: '3px',
marginBottom: '4px',
};
}
const showPathModal = ref(false); const showPathModal = ref(false);
const pathViewRecords = ref<PathLineRecord[]>([]); const pathViewRecords = ref<PathLineRecord[]>([]);
const pathPreviewContainer = ref<HTMLDivElement>(); const pathPreviewContainer = ref<HTMLDivElement>();
@ -410,7 +421,8 @@ async function drawPathPreview() {
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
if (!ctx) return; ctx.scale(dpr, dpr); if (!ctx) return; ctx.scale(dpr, dpr);
ctx.fillStyle = '#f8f8f8'; ctx.fillRect(0, 0, w, h); ctx.fillStyle = '#f8f8f8'; ctx.fillRect(0, 0, w, h);
let xMin = Infinity, xMax = -Infinity, yMin = Infinity, yMax = -Infinity; const sc = missionStore.mission.scanConfig;
let xMin = sc.xMin, xMax = sc.xMax, yMin = sc.yMin, yMax = sc.yMax;
for (const r of records) { xMin = Math.min(xMin, r.targetXMinPosition, r.targetXMaxPosition); xMax = Math.max(xMax, r.targetXMinPosition, r.targetXMaxPosition); yMin = Math.min(yMin, r.targetYPosition); yMax = Math.max(yMax, r.targetYPosition); } for (const r of records) { xMin = Math.min(xMin, r.targetXMinPosition, r.targetXMaxPosition); xMax = Math.max(xMax, r.targetXMinPosition, r.targetXMaxPosition); yMin = Math.min(yMin, r.targetYPosition); yMax = Math.max(yMax, r.targetYPosition); }
const rangeX = xMax - xMin || 1, rangeY = yMax - yMin || 1, pad = 30, drawW = w - pad * 2, drawH = h - pad * 2; const rangeX = xMax - xMin || 1, rangeY = yMax - yMin || 1, pad = 30, drawW = w - pad * 2, drawH = h - pad * 2;
const toCanvas = (wx: number, wy: number) => ({ x: pad + ((wx - xMin) / rangeX) * drawW, y: pad + ((yMax - wy) / rangeY) * drawH }); const toCanvas = (wx: number, wy: number) => ({ x: pad + ((wx - xMin) / rangeX) * drawW, y: pad + ((yMax - wy) / rangeY) * drawH });
@ -458,4 +470,5 @@ async function viewPathFile(filePath: string) { if (filePath) await openPathFile
<style scoped> <style scoped>
.mission-editor { height: 100vh; overflow: hidden; display: flex; flex-direction: column; } .mission-editor { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.main-panel { flex: 1; overflow-y: auto; } .main-panel { flex: 1; overflow-y: auto; }
.subtask-collapse :deep(.n-collapse-item__header) { padding-top: 0 !important; }
</style> </style>

View File

@ -31,7 +31,7 @@
</n-button> </n-button>
</n-space> </n-space>
<n-split direction="horizontal" :default-size="0.6"> <n-split direction="horizontal" :default-size="0.85">
<template #1> <template #1>
<ScanCanvas <ScanCanvas
v-model:regions="regions" v-model:regions="regions"
@ -41,6 +41,10 @@
:drawing-mode="drawingMode" :drawing-mode="drawingMode"
:drawing-shape="currentShape" :drawing-shape="currentShape"
:selected-index="selectedIndex" :selected-index="selectedIndex"
:x-min="missionStore.mission.scanConfig.xMin"
:x-max="missionStore.mission.scanConfig.xMax"
:y-min="missionStore.mission.scanConfig.yMin"
:y-max="missionStore.mission.scanConfig.yMax"
@select-region="selectedIndex = $event" @select-region="selectedIndex = $event"
@deselect="selectedIndex = -1" @deselect="selectedIndex = -1"
@add-region="onAddRegion" @add-region="onAddRegion"
@ -56,6 +60,8 @@
:mode="scanMode" :mode="scanMode"
:line-count="generatedRecords.length" :line-count="generatedRecords.length"
:est-time="estimatedTime" :est-time="estimatedTime"
:recommended-frame-rate="recommendedParams?.recommendedFrameRate ?? undefined"
:recommended-exposure-time="recommendedParams?.recommendedExposureTime ?? undefined"
@update="onParamChange" @update="onParamChange"
/> />
</template> </template>
@ -99,14 +105,15 @@ function getDeviceFov(): number {
const regions = ref<ScanRegion[]>([]); const regions = ref<ScanRegion[]>([]);
const camera = ref<CameraParams>({ fovDegrees: getDeviceFov(), heightCm: 50 }); const camera = ref<CameraParams>({ fovDegrees: getDeviceFov(), heightCm: 50 });
const coverageRate = ref(30); const coverageRate = ref(30);
const speedY = ref(5); const speedY = ref(10);
const speedXScan = ref(10); const speedXScan = ref(3);
const speedXStart = ref(20); const speedXStart = ref(10);
const scanMode = ref<ScanMode>('OneWay'); const scanMode = ref<ScanMode>('OneWay');
const generatedRecords = ref<PathLineRecord[]>([]); const generatedRecords = ref<PathLineRecord[]>([]);
const previewRecords = computed(() => generatedRecords.value); const previewRecords = computed(() => generatedRecords.value);
const estimatedTime = ref(0); const estimatedTime = ref(0);
const recommendedParams = ref<{recommendedFrameRate: number, recommendedExposureTime: number} | null>(null);
invoke<PlannerDefaults>('load_planner_defaults').then(p => { invoke<PlannerDefaults>('load_planner_defaults').then(p => {
coverageRate.value = p.coverageRate; coverageRate.value = p.coverageRate;
@ -171,6 +178,27 @@ async function generatePath() {
speedYCmS: speedY.value, speedXStartCmS: speedXStart.value, speedXScanCmS: speedXScan.value, mode: scanMode.value, speedYCmS: speedY.value, speedXStartCmS: speedXStart.value, speedXScanCmS: speedXScan.value, mode: scanMode.value,
}); });
estimatedTime.value = estTime; estimatedTime.value = estTime;
// 获取推荐相机参数
if (props.taskId !== null && props.subTaskId !== null) {
const task = missionStore.mission.tasks.find(t => t.id === props.taskId);
const sub = task?.subTasks.find(s => s.id === props.subTaskId);
if (sub) {
recommendedParams.value = await invoke<{recommendedFrameRate: number, recommendedExposureTime: number}>('recommend_hyperspectral_params', {
deviceType: sub.type,
heightCm: camera.value.heightCm,
fovDegrees: camera.value.fovDegrees,
scanSpeedCmS: speedXScan.value,
});
// 将推荐参数立即写入子任务
if (recommendedParams.value && DEVICE_FOV[sub.type]) {
sub.frameRate = recommendedParams.value.recommendedFrameRate;
sub.exposureTime = recommendedParams.value.recommendedExposureTime;
await missionStore.updateSubTask(props.taskId, { ...sub });
}
}
}
message.success(`航线生成完成: ${file.count} 条记录`); message.success(`航线生成完成: ${file.count} 条记录`);
} catch (e) { message.error('航线生成失败: ' + e); } } catch (e) { message.error('航线生成失败: ' + e); }
} }
@ -187,7 +215,15 @@ async function savePath() {
if (props.taskId !== null && props.subTaskId !== null) { if (props.taskId !== null && props.subTaskId !== null) {
const task = missionStore.mission.tasks.find(t => t.id === props.taskId); const task = missionStore.mission.tasks.find(t => t.id === props.taskId);
const sub = task?.subTasks.find(s => s.id === props.subTaskId); const sub = task?.subTasks.find(s => s.id === props.subTaskId);
if (sub) { sub.pathLineFilePath = finalPath; await missionStore.updateSubTask(props.taskId, { ...sub }); message.success('已自动填入子任务航线路径'); } if (sub) {
sub.pathLineFilePath = finalPath;
if (recommendedParams.value) {
sub.frameRate = recommendedParams.value.recommendedFrameRate;
sub.exposureTime = recommendedParams.value.recommendedExposureTime;
}
await missionStore.updateSubTask(props.taskId, { ...sub });
message.success('已自动填入子任务航线路径及推荐相机参数');
}
} }
} }
} catch (e) { message.error('保存失败: ' + e); } } catch (e) { message.error('保存失败: ' + e); }

View File

@ -1,5 +1,26 @@
# Spectral Insight Mission Plan - 更新日志 # Spectral Insight Mission Plan - 更新日志
## v0.0.10 (2026-06-25)
- 第一条航线 Y 坐标偏移 1/2 幅宽,不再紧贴绘制区域边缘
- 生成航线时自动计算推荐帧率和曝光时间(Pika L 900像元 / Pika NIR 320 像元,帧率×曝光时间=999)
- 生成航线后自动填入子任务帧率和曝光时间
- Pika L 最大帧率限制 250fps(唐超)
- Y 轴定位速度默认值修改为 10cm/s,X 扫描速度 3cm/s,X 回起点速度 10cm/s
## v0.0.9 (2026-06-25)
- 航线生成画布支持 scanConfig 坐标范围(修改 X/Y 范围后画布随之更新)
- 修复 Y 轴标签位数超过 3 位时溢出画布边框的问题
- 画布按扫描区域宽高比等比例显示(x:y 不再强制 1:1)
- 相机参数(FOV / 高度)改为纵向排列,右侧参数面板更窄
- 画布占比提升至 85%
## v0.0.8 (2026-06-22)
- 子任务按设备类型显示不同背景色和左侧色条(Pika L 绿 / Pika NIR 蓝 / 单反 橙 / 深度相机 红)
- 修复折叠时子任务标题高度不一致的问题
## v0.0.7 (2026-06-18) ## v0.0.7 (2026-06-18)
- fix: correct update.md v0.0.6 entry with proper 唐超 credit - fix: correct update.md v0.0.6 entry with proper 唐超 credit