添加 MX-PD-盘古 项目文件
将 MX-PD-盘古 - new 目录下的所有文件添加到主仓库
This commit is contained in:
@@ -0,0 +1,185 @@
|
||||
using MainShell.Hardware;
|
||||
using MaxwellFramework.Core.Common;
|
||||
using MaxwellFramework.Core.Interfaces;
|
||||
using MwFramework.Controls.Components;
|
||||
using MwFramework.Device;
|
||||
using MwFramework.ManagerService;
|
||||
using Stylet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
namespace MainShell.AlgorithmCalib.ViewModel
|
||||
{
|
||||
public class PixRatioCalibContentsViewModel:Screen,IPage
|
||||
{
|
||||
private HardwareManager _hardware;
|
||||
public ICommand PrevCommand { get; set; }
|
||||
public ICommand NextCommand { get; set; }
|
||||
private IParameterManager _parameterManager;
|
||||
public string Name { get; set; } = "PixRatioCalib";
|
||||
private bool _isInit = false;
|
||||
|
||||
private ObservableCollection<Screen> _screens;
|
||||
/// <summary>
|
||||
/// 需要显示的界面
|
||||
/// </summary>
|
||||
public ObservableCollection<Screen> Screens
|
||||
{
|
||||
get { return _screens; }
|
||||
set
|
||||
{ SetAndNotify(ref _screens, value); }
|
||||
}
|
||||
private Screen _showScreenVM;
|
||||
/// <summary>
|
||||
/// 当前显示界面的VM
|
||||
/// </summary>
|
||||
public Screen ShowScreenVM
|
||||
{
|
||||
get { return _showScreenVM; }
|
||||
set
|
||||
{ SetAndNotify(ref _showScreenVM, value); }
|
||||
}
|
||||
private string _currentCalibName;
|
||||
/// <summary>
|
||||
/// 当前标定名称,供UI标定
|
||||
/// </summary>
|
||||
public string CurrentCalibName
|
||||
{
|
||||
get { return _currentCalibName; }
|
||||
set { SetAndNotify(ref _currentCalibName, value); }
|
||||
}
|
||||
private string _progressText;
|
||||
/// <summary>
|
||||
/// 进度提示
|
||||
/// </summary>
|
||||
public string ProgressText
|
||||
{
|
||||
get { return _progressText; }
|
||||
set { SetAndNotify(ref _progressText, value); }
|
||||
}
|
||||
private int _showIndex;
|
||||
/// <summary>
|
||||
/// 当前显示界面的下标
|
||||
/// </summary>
|
||||
public int ShowIndex
|
||||
{
|
||||
get { return _showIndex; }
|
||||
set
|
||||
{ SetAndNotify(ref _showIndex, value); }
|
||||
}
|
||||
private bool _isEnablePrev;
|
||||
/// <summary>
|
||||
/// 上一个按钮是否启用
|
||||
/// </summary>
|
||||
public bool IsEnablePrev
|
||||
{
|
||||
get { return _isEnablePrev; }
|
||||
set
|
||||
{ SetAndNotify(ref _isEnablePrev, value); }
|
||||
}
|
||||
private bool _isEnableNext = true;
|
||||
/// <summary>
|
||||
/// 下一个按钮是否启用
|
||||
/// </summary>
|
||||
public bool IsEnableNext
|
||||
{
|
||||
get { return _isEnableNext; }
|
||||
set
|
||||
{ SetAndNotify(ref _isEnableNext, value); }
|
||||
}
|
||||
|
||||
public PixRatioCalibContentsViewModel(IParameterManager paraManager)
|
||||
{
|
||||
this._hardware = IoC.Get<HardwareManager>();
|
||||
this._parameterManager = paraManager;
|
||||
PrevCommand = new DelegateCommand(() =>
|
||||
{
|
||||
OnPrev();
|
||||
});
|
||||
|
||||
NextCommand = new DelegateCommand(() =>
|
||||
{
|
||||
OnNext();
|
||||
});
|
||||
}
|
||||
|
||||
#region view加载
|
||||
protected override void OnViewLoaded()
|
||||
{
|
||||
base.OnViewLoaded();
|
||||
if (!_isInit)
|
||||
{
|
||||
Screens = new ObservableCollection<Screen>();
|
||||
// ====== 定义5组相机-轴配置 ======
|
||||
var cameraConfigs = new List<(string Name, List<HardwareDevice> Device)>
|
||||
{
|
||||
("上相机像素比标定", _hardware.CameraAxisManager.TopCameraAxisDevices),
|
||||
("上相机WS像素比标定", _hardware.CameraAxisManager.TopCameraWsAxisDevices),
|
||||
("广角相机像素比标定", _hardware.CameraAxisManager.WideCameraAxisDevices),
|
||||
("广角相机WS像素比标定", _hardware.CameraAxisManager.WideCameraWsAxisDevices),
|
||||
("下相机像素比标定", _hardware.CameraAxisManager.BottomCameraAxisDevices),
|
||||
};
|
||||
|
||||
foreach (var (name, device) in cameraConfigs)
|
||||
{
|
||||
Screens.Add(PixRatioCalibViewModel.Create(name, device));
|
||||
}
|
||||
// 默认显示第一个
|
||||
ShowIndex = 0;
|
||||
ShowScreenVM = Screens[0];
|
||||
UpdateNavigationState();
|
||||
_isInit = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void viewUnLoad()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 按钮
|
||||
private void OnPrev()
|
||||
{
|
||||
if (ShowIndex <= 0) return;
|
||||
|
||||
ShowIndex--;
|
||||
ShowScreenVM = Screens[ShowIndex];
|
||||
UpdateNavigationState();
|
||||
}
|
||||
|
||||
private void OnNext()
|
||||
{
|
||||
if (ShowIndex >= Screens.Count - 1) return;
|
||||
|
||||
ShowIndex++;
|
||||
ShowScreenVM = Screens[ShowIndex];
|
||||
UpdateNavigationState();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 方法
|
||||
/// <summary>
|
||||
/// 统一更新导航状态和当前标定信息
|
||||
/// </summary>
|
||||
private void UpdateNavigationState()
|
||||
{
|
||||
IsEnablePrev = ShowIndex > 0;
|
||||
IsEnableNext = ShowIndex < Screens.Count - 1;
|
||||
|
||||
// 更新当前标定名称
|
||||
if (ShowScreenVM is PixRatioCalibViewModel camVm)
|
||||
{
|
||||
CurrentCalibName = camVm.CalibName;
|
||||
}
|
||||
|
||||
// 更新进度
|
||||
ProgressText = $"{ShowIndex + 1} / {Screens.Count}";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using MainShell.Hardware;
|
||||
using MaxwellFramework.Core.Common;
|
||||
using MaxwellFramework.Core.Interfaces;
|
||||
using MwFramework.Controls.SystemCalib;
|
||||
using MwFramework.ManagerService;
|
||||
using Stylet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace MainShell.AlgorithmCalib.ViewModel
|
||||
{
|
||||
public class PixRatioCalibViewModel:Screen,IPage
|
||||
{
|
||||
|
||||
public string Name { get; set; } = "CameraPixRatioCalib";
|
||||
public string CalibName { get; set; }
|
||||
|
||||
private CameraParaCalibViewModel _service;
|
||||
public CameraParaCalibViewModel Service
|
||||
{
|
||||
get { return _service; }
|
||||
set
|
||||
{
|
||||
_service = value;
|
||||
NotifyOfPropertyChange();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 标定名称标识(用于UI显示和逻辑判断)
|
||||
/// </summary>
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 无参构造函数
|
||||
/// </summary>
|
||||
public PixRatioCalibViewModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 手动创建时使用的静态工厂方法
|
||||
/// </summary>
|
||||
/// <param name="calibName">标定名称,如 "上相机像素比标定"</param>
|
||||
/// <param name="device">对应的硬件设备</param>
|
||||
public static PixRatioCalibViewModel Create(string calibName, List<HardwareDevice> device)
|
||||
{
|
||||
var vm = new PixRatioCalibViewModel();
|
||||
vm.Initialize(calibName, device);
|
||||
return vm;
|
||||
}
|
||||
|
||||
private void Initialize(string calibName, List<HardwareDevice> device)
|
||||
{
|
||||
CalibName = calibName;
|
||||
var paramList = IoC.Get<IParameterManager>() as IParamList;
|
||||
|
||||
Service = new CameraParaCalibViewModel(
|
||||
device,
|
||||
paramList,
|
||||
true
|
||||
);
|
||||
Service.IsShowSolidLine = true;
|
||||
Service.ShapeThickness = 1;
|
||||
Service.DrawInConcurrency = false;
|
||||
Service.IsAxisControlLDBVisible = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user