123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PaintDotNet.Annotation.ImageCollect
- {
- public enum LockType
- {
- NULL = 0,
- AREA = 1,
- SIZE = 2
- }
- public abstract class DrawStithchingBase : DrawObject
- {
- public static int ViewWidth = 2048;
- public static int ViewHeight = 2048;
- public static float Interval = 0.1f;
- private static int _OffsetX;
- private static int _OffsetY;
- public static int OffsetX { get => _OffsetX + SystemOffset; set { _OffsetX = value; } }
- public static int OffsetY { get => _OffsetY + SystemOffset; set { _OffsetY = value; } }
- private const int SystemOffset = 21;
- protected int[] tiles = new int[2];
- protected List<ZScanParameter> zscan = new List<ZScanParameter>();
- /// <summary>
- /// 锁定方式
- /// </summary>
- public static LockType lockType = LockType.NULL;
- protected RectangleF rectangleMax = new RectangleF();
- protected List<Dictionary<int, object>> _points = new List<Dictionary<int, object>>();
- /// <summary>
- /// 获取拼图区域划分的网格数
- /// </summary>
- public virtual int[] GetTiles()
- {
- int[] result = new int[2];
- result[0] = tiles[0];// * 2;
- result[1] = tiles[1];// * 2;
- return result;
- }
- public virtual int ColumnNum { get => tiles[0]; }
- public virtual int RowNum { get => tiles[1]; }
- public List<int> deletedPointId = new List<int>();
- /// <summary>
- /// 获取拼图区域面积
- /// </summary>
- /// <returns></returns>
- public virtual double GetArea()
- {
- double m_unitLength;
- this.ISurfaceBox.getMeasureInfo().TryGetValue(MeasurementUnit.Micron, out m_unitLength);
- double area = Math.Round((rectangleMax.Width * m_unitLength * rectangleMax.Height * m_unitLength / 1000000), 3);
- return area;
- }
- public virtual void Lock(LockType type)
- {
- lockType = type;
- }
- public virtual List<Dictionary<int, object>> GetViewPoints()
- {
- return _points;
- }
- public virtual void DeletePoint(int index)
- {
- deletedPointId.Add(index);
- }
- public virtual void SetZAxisScan(ZScanParameter zScanParameter, int pIndex = 999999)
- {
- if (pIndex == 999999)
- {
- zscan.Clear();
- for (int j = 0; j < tiles[1]; j++)
- {
- for (int i = 0; i < tiles[0]; i++)
- {
- zscan.Add(zScanParameter.Clone());
- }
- }
- }
- else
- {
- zscan[pIndex] = zScanParameter.Clone();
- }
- }
- public virtual ZScanParameter GetZAxisScan(int index)
- {
- return zscan[index];
- }
- /// <summary>
- /// 计算偏移后的点
- /// </summary>
- protected Func<float, float, PointF> OffsetPointF = (x, y) => new PointF(x + OffsetX, y + OffsetY);
- }
- public class ZScanParameter
- {
- public double Start;
- public double Stop;
- public int Times = 5;
- public double Track;
- public ZScanParameter Clone()
- {
- return MemberwiseClone() as ZScanParameter;
- }
- }
- }
|