76 lines
2.7 KiB
C#
76 lines
2.7 KiB
C#
using System;
|
|
using Aurora.Api;
|
|
using Aurora.Api.DataType;
|
|
using Aurora.View;
|
|
using VisionCommon;
|
|
using MilPattern;
|
|
|
|
namespace MilUI {
|
|
public class MultiLineParamSettingViewModel : NotifyPropertyChangedBase, IGraEventSubscriber {
|
|
private Logger _logger = new Logger(typeof(MultiLineParamSettingViewModel).Name);
|
|
|
|
#region Binding Properties
|
|
private PatternInfo _patternInfo;
|
|
public PatternInfo PatternInfo { get => _patternInfo; set => SetProperty(ref _patternInfo, value); }
|
|
|
|
private LineFinderRunParam _runParam;
|
|
public LineFinderRunParam RunParam { get => _runParam; set => SetProperty(ref _runParam, value); }
|
|
|
|
private int _LineIdx;
|
|
public int LineIdx { get => _LineIdx; set => SetProperty(ref _LineIdx, value); }
|
|
#endregion
|
|
|
|
private PatternAgentBase _patternAgent;
|
|
private CameraDisplay _cameraDisplay;
|
|
private FovInfo _fovInfo;
|
|
|
|
public MultiLineParamSettingViewModel(
|
|
PatternAgentBase patternAgent, PatternInfo patternInfo, CameraDisplay cameraDisplay, FovInfo fovInfo, int lineIdx) {
|
|
|
|
_patternAgent = patternAgent;
|
|
_patternInfo = patternInfo;
|
|
_cameraDisplay = cameraDisplay;
|
|
_fovInfo = fovInfo;
|
|
LineIdx = lineIdx;
|
|
|
|
InitRunParam();
|
|
_cameraDisplay.SetGraEventSubscriber(_patternInfo, this);
|
|
}
|
|
|
|
public void InitRunParam() {
|
|
if (_patternAgent.IsPatternExist(_patternInfo.GetPatternIndex())) {
|
|
RunParam = _patternAgent.GetRunParam(_patternInfo) as LineFinderRunParam;
|
|
}
|
|
else {
|
|
RunParam = new LineFinderRunParam();
|
|
}
|
|
}
|
|
|
|
private void SetFindROI(object obj) {
|
|
|
|
}
|
|
|
|
private ROI GetFindROIFromRunParam(ImageSize imageSize, LineFinderRunParam runParam) {
|
|
if ((0 < runParam.FindROI.Width && runParam.FindROI.Width < imageSize.Width) &&
|
|
(0 < runParam.FindROI.Height && runParam.FindROI.Height < imageSize.Height)) {
|
|
return runParam.FindROI.Clone() as ROI;
|
|
}
|
|
|
|
return new ROI(
|
|
new ImagePoint(imageSize.Width * 0.5, imageSize.Height * 0.5),
|
|
100, 300,
|
|
Angle.CreateWithDegree(0));
|
|
}
|
|
|
|
public void UpdateAngleOfFindRoi(double roiAngle) {
|
|
_cameraDisplay.UpdateAngleOfFindRoi(roiAngle);
|
|
}
|
|
|
|
public void UpdateAngleOfRoi(eGraRoiType graRoiType, object param) {
|
|
if (graRoiType == eGraRoiType.FindRoi) {
|
|
RunParam.FindROI.Angle.Degree = Math.Round((double)param, 1);
|
|
NotifyPropertyChanged(nameof(RunParam));
|
|
}
|
|
}
|
|
}
|
|
} |