using HalconDotNet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Community;
using Model;
using Model.Vision;
using System.Windows;
using System.Collections.ObjectModel;
namespace ViewModel.Vision
{
///
/// 测量VM
///
partial class HalconVisual
{
///
/// 边缘测量编辑
///
public DelegateCommand EdgeMeasureEditCommand { get; set; }
///
/// 边缘测量测试
///
public DelegateCommand EdgeMeasureTestCommand { get; set; }
///
/// 测量数据保存
///
public DelegateCommand MeasureSaveCommand { get; set; }
#region 高斯平滑的Sigma
private double m_Sigma;
///
/// 高斯平滑的Sigma
///
public double M_Sigma
{
get { return m_Sigma; }
set
{
m_Sigma = value;
if (ContinuousChange)
{
SelectModel.MyROI.M_Sigma = value;
MeasureLineEdge(SelectModel);
}
this.RaisePropertyChanged("M_Sigma");
}
}
#endregion
#region 最小边缘幅度
private double m_Threshold;
///
/// 最小边缘幅度
///
public double M_Threshold
{
get { return m_Threshold; }
set
{
m_Threshold = value;
if (ContinuousChange)
{
SelectModel.MyROI.M_Threshold = value;
MeasureLineEdge(SelectModel);
}
this.RaisePropertyChanged("M_Threshold");
}
}
#endregion
#region 边缘分组方式
private string m_Transition;
///
/// 边缘分组方式,值列表:'all','positive','negative','all_strongest','positive_strongest','negative_strongest'
///
public string M_Transition
{
get { return m_Transition; }
set
{
m_Transition = value;
if (ContinuousChange)
{
SelectModel.MyROI.M_Transition = value;
MeasureLineEdge(SelectModel);
}
this.RaisePropertyChanged("M_Transition");
}
}
private ObservableCollection m_TransitionList;
///
/// 边缘分组类型List
///
public ObservableCollection M_TransitionList
{
get { return m_TransitionList; }
set
{
m_TransitionList = value;
this.RaisePropertyChanged("M_TransitionList");
}
}
#endregion
#region 选择边缘对的方式
private string m_Select;
///
/// 选择边缘对的方式 值列表:'all','first','last'
///
public string M_Select
{
get { return m_Select; }
set
{
m_Select = value;
if (ContinuousChange)
{
SelectModel.MyROI.M_Select = value;
MeasureLineEdge(SelectModel);
}
this.RaisePropertyChanged("M_Select");
}
}
private ObservableCollection m_SelectList;
///
/// 边缘选择方式List
///
public ObservableCollection M_SelectList
{
get { return m_SelectList; }
set
{
m_SelectList = value;
this.RaisePropertyChanged("M_SelectList");
}
}
#endregion
#region 插值方法
private string m_Interpolation;
///
/// 插值方法 默认值是 nearest_neighbor。是最近点的意思。 还可以写bilinear(双线性),bicubic(双三次)
///
public string M_Interpolation
{
get { return m_Interpolation; }
set
{
m_Interpolation = value;
if (ContinuousChange)
{
SelectModel.MyROI.M_Interpolation = value;
MeasureLineEdge(SelectModel);
}
this.RaisePropertyChanged("M_Interpolation");
}
}
private ObservableCollection m_InterpolationList;
///
/// 插值方法List
///
public ObservableCollection M_InterpolationList
{
get { return m_InterpolationList; }
set
{
m_InterpolationList = value;
this.RaisePropertyChanged("M_Interpolation");
}
}
#endregion
///
/// 是否可以进行,参数变化实时调整
///
bool ContinuousChange { get; set; }
#region 测量初始化
///
/// 测量初始化
///
public void MeasureInitialize()
{
M_Sigma = 1;
M_Threshold = 30;
M_Transition = "all";
M_Select = "all";
M_Interpolation = "nearest_neighbor";
//值列表:'all','positive','negative','all_strongest','positive_strongest','negative_strongest'
M_TransitionList = new ObservableCollection() { new CommonClass() { ID=1, CommonName="all", ShortCode= "all" },
new CommonClass() { ID=1, CommonName="positive", ShortCode= "positive" },
new CommonClass() { ID=1, CommonName="negative", ShortCode= "negative" },
new CommonClass() { ID=1, CommonName="all_strongest", ShortCode= "all_strongest" },
new CommonClass() { ID=1, CommonName="positive_strongest", ShortCode= "positive_strongest" },
new CommonClass() { ID=1, CommonName="negative_strongest", ShortCode= "negative_strongest" }};
//值列表:'all','first','last'
M_SelectList = new ObservableCollection() { new CommonClass() { ID=1, CommonName="all", ShortCode= "all" },
new CommonClass() { ID=1, CommonName="first", ShortCode= "first" },
new CommonClass() { ID=1, CommonName="last", ShortCode= "last" }};
//提取边缘最近点作为参考像素, 默认值是 nearest_neighbor。是最近点的意思。 还可以写bilinear(双线性),bicubic(双三次)
M_InterpolationList = new ObservableCollection() { new CommonClass() { ID=1, CommonName="nearest_neighbor", ShortCode= "nearest_neighbor" },
new CommonClass() { ID=1, CommonName="bilinear", ShortCode= "bilinear" },
new CommonClass() { ID=1, CommonName="bicubic", ShortCode= "bicubic" }};
EdgeMeasureEditCommand = new DelegateCommand();
EdgeMeasureEditCommand.ExecuteAction = new Action