private bool isLine(PositionModel line)
 {
     return (line.RowBegin > 0 && line.ColBegin > 0 && line.RowEnd > 0 && line.ColEnd > 0);
 }
        private void init()
        {
            this.NumHandles = 2;//移動用的 Handle, 1 middle point, 整條線
            _dependROIModels = new List<PositionModel>();
            if (_model != null)
            {
                //原始值
                _rawCenterRow = (_model.RowBegin + _model.RowEnd) / 2.0;
                _rawCenterCol = (_model.ColBegin + _model.ColEnd) / 2.0;
                _halfDistance = _model.Distance / 2.0;

                var radStart = HMisc.AngleLx(_rawCenterRow, _rawCenterCol, _model.RowBegin, _model.ColBegin);
                _phiStart = halconRadToNormalRad(radStart);

                var radEnd = HMisc.AngleLx(_rawCenterRow, _rawCenterCol, _model.RowEnd, _model.ColEnd);
                _phiEnd = halconRadToNormalRad(radEnd);

                this.NewCenterRow = (!_model.UserDefineCenterRow.HasValue) ? _rawCenterRow : _model.UserDefineCenterRow.Value;
                this.NewCenterCol = (!_model.UserDefineCenterCol.HasValue) ? _rawCenterCol : _model.UserDefineCenterCol.Value;

                this.ID = _model.ID;
                Name = _model.Name;

                //_modelPoints = new List<PositionModel>() {
                //	new PositionModel(){ RowBegin =_model.RowBegin, ColBegin = _model.ColBegin },
                //	new PositionModel(){ RowBegin =_model.RowEnd, ColBegin = _model.ColEnd },
                //};

                if (_model.ROIs != null)
                {
                    var basicGeoType = new List<MeasureType>() {
                                            {MeasureType.FitLine},
                                            {MeasureType.Line},
                                            {MeasureType.Point},
                                            {MeasureType.Circle}
                                        };
                    for (var i = 0; i < _model.ROIs.Length; i++)
                    {
                        var roiModel = _model.ROIs[i];

                        PositionModel dto;
                        if (roiModel.RowBegin > 0
                            && roiModel.ColBegin > 0
                            && roiModel.RowEnd > 0
                            && roiModel.ColEnd > 0)
                        {
                            dto = new PositionModel()
                            {
                                RowBegin = roiModel.RowBegin,
                                ColBegin = roiModel.ColBegin,
                                RowEnd = roiModel.RowEnd,
                                ColEnd = roiModel.ColEnd,
                            };
                            _ROIModelPoints.Add(new PositionModel()
                            {
                                RowBegin = (roiModel.RowBegin + roiModel.RowEnd) / 2.0,
                                ColBegin = (roiModel.ColBegin + roiModel.ColEnd) / 2.0
                            });
                        }
                        else
                        {
                            dto = new PositionModel()
                            {
                                RowBegin = roiModel.RowBegin,
                                ColBegin = roiModel.ColBegin,
                            };
                            _ROIModelPoints.Add(new PositionModel()
                            {
                                RowBegin = (roiModel.RowBegin),
                                ColBegin = (roiModel.ColBegin)
                            });
                        }
                        if (basicGeoType.Contains(roiModel.GeoType))
                            _dependROIModels.Add(dto);
                    }
                    _ROIModelPoints = _ROIModelPoints.OrderBy(x => x.ColBegin).OrderBy(y => y.RowBegin).ToList();

                }
            }
        }
Пример #3
0
        private void init()
        {
            this.NumHandles = 1;//移動用的 Handle, 1 middle point
            _lines = new List<PositionModel>();
            _rawCenterRow = _rawCenterCol = -1;
            _lineACenterRow = _lineACenterRow = _lineBCenterRow = _lineBCenterRow = -1;
            if (_model != null)
            {
                this.ID = _model.ID;
                this.Name = _model.Name;

                if (_model.ROIs != null)
                {
                    for (var i = 0; i < _model.ROIs.Length; i++)
                    {
                        var roiModel = _model.ROIs[i];
                        if (roiModel.RowBegin < 0
                            && roiModel.ColBegin < 0
                            && roiModel.RowEnd < 0
                            && roiModel.ColEnd < 0) continue;

                        var dto = new PositionModel()
                        {
                            RowBegin = roiModel.RowBegin,
                            ColBegin = roiModel.ColBegin,
                            RowEnd = roiModel.RowEnd,
                            ColEnd = roiModel.ColEnd,
                        };
                        _lines.Add(dto);
                    }

                    if (_lines.Count > 1)
                    {
                        _lineACenterRow = _rawCenterRow = (_lines[0].RowBegin + _lines[0].RowEnd) / 2.0;
                        _lineACenterCol = _rawCenterCol = (_lines[0].ColBegin + _lines[0].ColEnd) / 2.0;

                        _lineBCenterRow = (_lines[1].RowBegin + _lines[1].RowEnd) / 2.0;
                        _lineBCenterCol = (_lines[1].ColBegin + _lines[1].ColEnd) / 2.0;
                    }
                }
                this.NewCenterRow = (!_model.UserDefineCenterRow.HasValue) ? _rawCenterRow : _model.UserDefineCenterRow.Value;
                this.NewCenterCol = (!_model.UserDefineCenterCol.HasValue) ? _rawCenterCol : _model.UserDefineCenterCol.Value;
            }
        }
        private void init()
        {
            _lines = new List<PositionModel>();
            if (_model != null)
            {
                this.NumHandles = 1; //整個線段
                this.ID = _model.ID;
                this.Name = _model.Name;

                //原始值
                _rawCenterRow = (_model.RowBegin + _model.RowEnd) / 2.0;
                _rawCenterCol = (_model.ColBegin + _model.ColEnd) / 2.0;

                if (_model.ROIs != null)
                {
                    for (var i = 0; i < _model.ROIs.Length; i++)
                    {
                        var roiModel = _model.ROIs[i];
                        if (roiModel.RowBegin < 0
                            && roiModel.ColBegin < 0
                            && roiModel.RowEnd < 0
                            && roiModel.ColEnd < 0) continue;

                        var dto = new PositionModel()
                        {
                            RowBegin = roiModel.RowBegin,
                            ColBegin = roiModel.ColBegin,
                            RowEnd = roiModel.RowEnd,
                            ColEnd = roiModel.ColEnd,
                        };
                        _lines.Add(dto);
                    }
                }
            }
        }
Пример #5
0
        private void init()
        {
            this.NumHandles = 1;
            _lines = new List<PositionModel>();
            if (_model != null)
            {
                //原始值
                this.Name = _model.Name;
                this.ID = _model.ID;

                //點
                _rawPointRow = (_model.RowBegin);
                _rawPointCol = (_model.ColBegin);

                //如果此點有相依的線段元素
                if (_model.ROIs != null)
                {
                    for (var i = 0; i < _model.ROIs.Length; i++)
                    {
                        var roiModel = _model.ROIs[i];
                        if (roiModel.RowBegin < 0
                            && roiModel.ColBegin < 0
                            && roiModel.RowEnd < 0
                            && roiModel.ColEnd < 0) continue;

                        var dto = new PositionModel()
                        {
                            RowBegin = roiModel.RowBegin,
                            ColBegin = roiModel.ColBegin,
                            RowEnd = roiModel.RowEnd,
                            ColEnd = roiModel.ColEnd,
                        };
                        _lines.Add(dto);
                    }
                }
            }
        }