136 lines
4.1 KiB
C#
136 lines
4.1 KiB
C#
/*
|
|
* Copyright (c) 2025 LG Electronics Inc.
|
|
* SPDX-License-Identifier: LicenseRef-LGE-Proprietary
|
|
*/
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows;
|
|
using System.Windows.Input;
|
|
using Aurora.Api;
|
|
using Aurora.View;
|
|
using VisionCommon;
|
|
using VisionCommonUI;
|
|
|
|
#if USE_COGNEX
|
|
using CogUI;
|
|
#else
|
|
using MilUI;
|
|
using MilPattern;
|
|
#endif
|
|
|
|
namespace VisionUI {
|
|
public class MultiLineSettingViewModel : NotifyPropertyChangedBase {
|
|
private Logger _logger = new Logger(typeof(MultiLineSettingViewModel).Name);
|
|
|
|
public ICommand CMD_Cancel { get; }
|
|
public ICommand CMD_SetLight { get; }
|
|
public ICommand CMD_SetPreProc { get; }
|
|
|
|
private bool _isStripe;
|
|
public bool IsStripe { get => _isStripe; set => SetProperty(ref _isStripe, value); }
|
|
|
|
private PatternInfo _patternInfo;
|
|
public PatternInfo PatternInfo { get => _patternInfo; set => SetProperty(ref _patternInfo, value); }
|
|
|
|
#if !USE_COGNEX
|
|
private LineFinderRunParam _runParam;
|
|
public LineFinderRunParam RunParam { get => _runParam; set => SetProperty(ref _runParam, value); }
|
|
|
|
#endif
|
|
private IEnumerable<int> _fixturePatterns;
|
|
public IEnumerable<int> FixturePatterns { get => _fixturePatterns; set => SetProperty(ref _fixturePatterns, value); }
|
|
|
|
private PatternAgentBase _patternAgent;
|
|
private ICameraDisplay _cameraDisplay;
|
|
private FovInfo _fovInfo;
|
|
private Window _preProcWindow = null;
|
|
|
|
public MultiLineSettingViewModel(
|
|
PatternAgentBase patternAgent, PatternInfo patternInfo, ICameraDisplay cameraDisplay, FovInfo fovInfo) {
|
|
|
|
_patternAgent = patternAgent;
|
|
_patternInfo = patternInfo;
|
|
_cameraDisplay = cameraDisplay;
|
|
_fovInfo = fovInfo;
|
|
|
|
CMD_Cancel = new DelegateCommand(Cancel);
|
|
CMD_SetLight = new DelegateCommand(SetLight);
|
|
CMD_SetPreProc = new DelegateCommand(SetPreProc);
|
|
|
|
Update();
|
|
}
|
|
|
|
private void Update() {
|
|
InitRunParam();
|
|
InitFixturePatterns();
|
|
}
|
|
|
|
public void InitRunParam() {
|
|
#if !USE_COGNEX
|
|
|
|
if (_patternAgent.IsPatternExist(_patternInfo.GetPatternIndex())) {
|
|
RunParam = _patternAgent.GetRunParam(_patternInfo) as LineFinderRunParam;
|
|
}
|
|
else {
|
|
RunParam = new LineFinderRunParam();
|
|
}
|
|
IsStripe = RunParam.MrkParamExt.IsStripe;
|
|
#endif
|
|
}
|
|
|
|
public void InitFixturePatterns() {
|
|
FixturePatterns = _patternAgent.GetFixturePatternIndexListForFov(_patternInfo);
|
|
}
|
|
|
|
private void Cancel(object obj) {
|
|
CloseChildWindow();
|
|
CloseWindow(obj);
|
|
}
|
|
|
|
private void CloseWindow(object obj) {
|
|
var window = obj as Window;
|
|
if (window != null) {
|
|
window.Close();
|
|
}
|
|
}
|
|
|
|
private void CloseChildWindow() {
|
|
if (_preProcWindow != null) {
|
|
_preProcWindow.Close();
|
|
}
|
|
}
|
|
|
|
private void SetLight(object obj) {
|
|
PatternLightWindowManager.ShowLightSettingWindow(_fovInfo, _patternInfo);
|
|
}
|
|
|
|
private void SetPreProc(object obj) {
|
|
if (_preProcWindow == null) {
|
|
_preProcWindow = new PreProcessingWindow(_patternInfo, _cameraDisplay);
|
|
(_preProcWindow as IPatternSettingWindow).ResetPosition();
|
|
_preProcWindow.Closed += OnWindowClosed;
|
|
_preProcWindow.Owner = Application.Current.MainWindow;
|
|
_preProcWindow.Show();
|
|
}
|
|
else {
|
|
ResetWindow();
|
|
}
|
|
}
|
|
|
|
public void Save() {
|
|
_patternAgent.Save(_patternInfo);
|
|
}
|
|
|
|
private void ResetWindow() {
|
|
if (_preProcWindow.WindowState == WindowState.Minimized) {
|
|
_preProcWindow.WindowState = WindowState.Normal;
|
|
}
|
|
|
|
(_preProcWindow as IPatternSettingWindow).ResetPosition();
|
|
}
|
|
|
|
private void OnWindowClosed(object sender, EventArgs e) {
|
|
_preProcWindow = null;
|
|
}
|
|
}
|
|
} |