123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677 |
- using PaintDotNet.Base.SettingModel;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- namespace PaintDotNet.DedicatedAnalysis.GrainSizeStandard.IntegrationClass
- {
- /// <summary>
- /// 需要根据当前操作图片备份和读取的辅助线数据
- /// </summary>
- class GrainSizeGuideModel
- {
- public string oldSelectItem;
- /// <summary>
- /// 辅助线位置
- /// </summary>
- public PointF loctation;
- /// <summary>
- /// 辅助线区域
- /// </summary>
- public RectangleF rectangleFLine = new RectangleF();
- //辅助线缩放控制
- public float originWidth = 1;
- public float originHeight = 1;
- //辅助线缩放控制(物理长度)
- public float rectangleFLineWidth = 1;
- public float rectangleFLineHeight = 1;
- /// <summary>
- /// 矩形宽
- /// </summary>
- public double lineRectangleWidth;
- public double originLineRectangleWidth;
- /// <summary>
- /// 矩形高
- /// </summary>
- public double lineRectangleHeight;
- public double originLineRectangleHeight;
- /// <summary>
- /// 直径
- /// </summary>
- public double lineDiameter;
- public double originLineDiameter;
- /// <summary>
- /// 长度(物理长度)
- /// </summary>
- public int lineLength;
- public float mat_lineLength;
- public double originLineLength;
- /// <summary>
- /// 间距
- /// </summary>
- public float mat_lineSpacing;
- public double originMat_lineSpacing;
- private double originLineSpacing;
- /// <summary>
- /// 线条数
- /// </summary>
- public int lineDec;
- /// <summary>
- /// 直径(物理长度)
- /// </summary>
- public double diameter;
- public float mat_diameter;
- public double originDiameter;
- /// <summary>
- /// 边距(物理长度)
- /// </summary>
- public double margin;
- public float mat_margin;
- public double originMargin;
- /// <summary>
- /// 长度(垂线)(物理长度)
- /// </summary>
- private double originVLineLength;
- public int vLineLength;
- public float mat_vLineLength;
- /// <summary>
- /// 长度(水平线)(物理长度)
- /// </summary>
- private double originHLineLength;
- public int hLineLength;
- public float mat_hLineLength;
- /// <summary>
- /// 左上到右下斜线长度(物理长度)
- /// </summary>
- private double originTopleftLineLength;
- public int TopleftLineLength;
- public float mat_TopleftLineLength;
- /// <summary>
- /// 左下到右上斜线长度(物理长度)
- /// </summary>
- private double originToprightLineLength;
- public int ToprightLineLength;
- public float mat_ToprightLineLength;
- /// <summary>
- /// 垂线到圆距离
- /// </summary>
- private float VLineToCDistance;
- public float mat_VLineToCDistance;
- public double originVLineToCDistance;
- /// <summary>
- /// 水平线到圆距离(物理长度)
- /// </summary>
- private float HLineToCDistance;
- public float mat_HLineToCDistance;
- public double originHLineToCDistance;
- /// <summary>
- /// 线颜色
- /// </summary>
- public int lineColor;
- /// <summary>
- /// 线宽
- /// </summary>
- public int lineWidth;
- /// <summary>
- /// 找到当前的参数数据
- /// </summary>
- /// <param name="menuId"></param>
- /// <returns></returns>
- public GrainSizeGuideModel cloneListParamModel()
- {
- GrainSizeGuideModel newMod = new GrainSizeGuideModel();
- newMod.oldSelectItem = this.oldSelectItem;//######################################
- ////newMod.ListParam = new List<GrainSizeAnalysisModel>();
- ////foreach (var item in this.ListParam)
- //// if (item.menuId == menuId)
- //// newMod.ListParam.Add(item.cloneModel());
- return newMod;
- }
- public GrainSizeGuideModel cloneModel()
- {
- GrainSizeGuideModel newMod = new GrainSizeGuideModel();
- newMod.oldSelectItem = this.oldSelectItem;
- newMod.loctation = new PointF(loctation.X, loctation.Y);
- newMod.rectangleFLine = new RectangleF(rectangleFLine.X, rectangleFLine.Y, rectangleFLine.Width, rectangleFLine.Height);
- newMod.originWidth = this.originWidth;
- newMod.originHeight = this.originHeight;
- newMod.rectangleFLineWidth = this.rectangleFLineWidth;
- newMod.rectangleFLineHeight = this.rectangleFLineHeight;
- newMod.lineRectangleWidth = this.lineRectangleWidth;
- newMod.originLineRectangleWidth = this.originLineRectangleWidth;
- newMod.lineRectangleHeight = this.lineRectangleHeight;
- newMod.originLineRectangleHeight = this.originLineRectangleHeight;
- newMod.lineDiameter = this.lineDiameter;
- newMod.originLineDiameter = this.originLineDiameter;
- newMod.lineLength = this.lineLength;
- newMod.mat_lineLength = this.mat_lineLength;
- newMod.originLineLength = this.originLineLength;
- newMod.mat_lineSpacing = this.mat_lineSpacing;
- newMod.originMat_lineSpacing = this.originMat_lineSpacing;
- newMod.originLineSpacing = this.originLineSpacing;
- newMod.lineDec = this.lineDec;
- newMod.diameter = this.diameter;
- newMod.mat_diameter = this.mat_diameter;
- newMod.originDiameter = this.originDiameter;
- newMod.margin = this.margin;
- newMod.mat_margin = this.mat_margin;
- newMod.originMargin = this.originMargin;
- newMod.vLineLength = this.vLineLength;
- newMod.mat_vLineLength = this.mat_vLineLength;
- newMod.hLineLength = this.hLineLength;
- newMod.mat_hLineLength = this.mat_hLineLength;
- newMod.TopleftLineLength = this.TopleftLineLength;
- newMod.mat_TopleftLineLength = this.mat_TopleftLineLength;
- newMod.ToprightLineLength = this.ToprightLineLength;
- newMod.mat_ToprightLineLength = this.mat_ToprightLineLength;
- newMod.VLineToCDistance = this.VLineToCDistance;
- newMod.mat_VLineToCDistance = this.mat_VLineToCDistance;
- newMod.originVLineToCDistance = this.originVLineToCDistance;
- newMod.HLineToCDistance = this.HLineToCDistance;
- newMod.mat_HLineToCDistance = this.mat_HLineToCDistance;
- newMod.originHLineToCDistance = this.originHLineToCDistance;
- newMod.lineColor = this.lineColor;
- newMod.lineWidth = this.lineWidth;
- return newMod;
- }
- public RectangleF RectangleFLine
- {
- get
- {
- return this.rectangleFLine;
- }
- set
- {
- this.rectangleFLine = value;
- }
- }
- /// <summary>
- /// 绘制辅助线(垂直辅助线)
- /// </summary>
- public void DrawGuideLines1(Graphics graphics)
- {
- Matrix mtxSave = graphics.Transform;
- Matrix matrix = graphics.Transform;
- // 以下为绘制样式
- Pen linePen = new Pen(Color.FromArgb(this.lineColor), this.lineWidth);
- if (this.lineDec % 2 == 0)
- {
- float Spacing = (float)this.mat_lineSpacing / 2;
- for (int i = 0; i < (float)this.lineDec / 2; i++)
- {
- graphics.DrawLine(linePen, new PointF((float)this.rectangleFLine.X + this.lineWidth / 2 + (this.rectangleFLine.Width - this.lineWidth) / 2 - Spacing, this.rectangleFLine.Top)
- , new PointF((float)this.rectangleFLine.X + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Width - this.lineWidth) / 2 - Spacing, this.rectangleFLine.Bottom));
- graphics.DrawLine(linePen, new PointF((float)this.rectangleFLine.X + this.lineWidth / 2 + (this.rectangleFLine.Width - this.lineWidth) / 2 + Spacing, this.rectangleFLine.Top)
- , new PointF((float)this.rectangleFLine.X + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Width - this.lineWidth) / 2 + Spacing, this.rectangleFLine.Bottom));
- Spacing += this.mat_lineSpacing;
- }
- }
- else
- {
- if (this.lineDec == 1)
- {
- graphics.DrawLine(linePen, new PointF(this.rectangleFLine.X + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Width - this.lineWidth) / 2, this.rectangleFLine.Top)
- , new PointF(this.rectangleFLine.X + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Width - this.lineWidth) / 2, this.rectangleFLine.Bottom));
- }
- else
- {
- float Spacing = this.mat_lineSpacing;
- for (int i = 0; i < (this.lineDec - 1) / 2; i++)
- {
- if (i == 0)
- graphics.DrawLine(linePen, new PointF(this.rectangleFLine.X + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Width - this.lineWidth) / 2, this.rectangleFLine.Top)
- , new PointF(this.rectangleFLine.X + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Width - this.lineWidth) / 2, this.rectangleFLine.Bottom));
- graphics.DrawLine(linePen, new PointF(this.rectangleFLine.X + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Width - this.lineWidth) / 2 + Spacing, this.rectangleFLine.Top)
- , new PointF(this.rectangleFLine.X + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Width - this.lineWidth) / 2 + Spacing, this.rectangleFLine.Bottom));
- graphics.DrawLine(linePen, new PointF(this.rectangleFLine.X + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Width - this.lineWidth) / 2 - Spacing, this.rectangleFLine.Top)
- , new PointF(this.rectangleFLine.X + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Width - this.lineWidth) / 2 - Spacing, this.rectangleFLine.Bottom));
- Spacing += this.mat_lineSpacing;
- }
- }
- }
- Pen pen = new Pen(Color.FromArgb(this.lineColor), 1);
- pen.DashStyle = DashStyle.DashDotDot;
- //使用自定义线型
- float[] dashArray = {
- 2.0f, //线长2个像素
- 5.0f, //间断5个像素
- 2.0f, //线长2个像素
- 5.0f //间断5个像素
- };
- pen.DashPattern = dashArray;
- graphics.DrawRectangle(pen, new Rectangle((int)this.rectangleFLine.X, (int)this.rectangleFLine.Y, (int)this.rectangleFLine.Width, (int)this.rectangleFLine.Height));
- pen.Dispose();
- //显示辅助线像素长度
- SizeF sizeF = graphics.MeasureString("" + this.lineLength, new System.Drawing.Font("宋体", 20));
- matrix.RotateAt((float)270, new PointF(this.rectangleFLine.Left - sizeF.Height, this.rectangleFLine.Top + sizeF.Width));
- graphics.Transform = matrix;
- graphics.DrawString("" + this.lineLength, new System.Drawing.Font("宋体", 20), new SolidBrush(Color.Black), new PointF(this.rectangleFLine.Left - sizeF.Height, this.rectangleFLine.Top + sizeF.Width));
- graphics.Transform = mtxSave;
- }
- /// <summary>
- /// 绘制辅助线(水平辅助线)
- /// </summary>
- public void DrawGuideLines2(Graphics graphics)
- {
- // 以下为绘制样式
- Pen linePen = new Pen(Color.FromArgb(this.lineColor), this.lineWidth);
- if (this.lineDec % 2 == 0)
- {
- float Spacing = (float)this.mat_lineSpacing / 2;
- for (int i = 0; i < (float)this.lineDec / 2; i++)
- {
- graphics.DrawLine(linePen, new PointF(this.rectangleFLine.Left, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2 - Spacing)
- , new PointF(this.rectangleFLine.Right, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2 - Spacing));
- graphics.DrawLine(linePen, new PointF(this.rectangleFLine.Left, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2 + Spacing)
- , new PointF(this.rectangleFLine.Right, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2 + Spacing));
- Spacing += this.mat_lineSpacing;
- }
- }
- else
- {
- if (this.lineDec == 1)
- {
- graphics.DrawLine(linePen, new PointF(this.rectangleFLine.Left, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2)
- , new PointF(this.rectangleFLine.Right, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2));
- }
- else
- {
- float Spacing = this.mat_lineSpacing;
- for (int i = 0; i < (this.lineDec - 1) / 2; i++)
- {
- if (i == 0)
- graphics.DrawLine(linePen, new PointF(this.rectangleFLine.Left, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2)
- , new PointF(this.rectangleFLine.Right, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2));
- graphics.DrawLine(linePen, new PointF(this.rectangleFLine.Left, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2 - Spacing)
- , new PointF(this.rectangleFLine.Right, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2 - Spacing));
- graphics.DrawLine(linePen, new PointF(this.rectangleFLine.Left, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2 + Spacing)
- , new PointF(this.rectangleFLine.Right, this.rectangleFLine.Y + (float)this.lineWidth / 2 + (float)(this.rectangleFLine.Height - this.lineWidth) / 2 + Spacing));
- Spacing += this.mat_lineSpacing;
- }
- }
- }
- Pen pen = new Pen(Color.FromArgb(this.lineColor), 1);
- pen.DashStyle = DashStyle.DashDotDot;
- //使用自定义线型
- float[] dashArray = {
- 2.0f, //线长2个像素
- 5.0f, //间断5个像素
- 2.0f, //线长2个像素
- 5.0f //间断5个像素
- };
- pen.DashPattern = dashArray;
- graphics.DrawRectangle(pen, new Rectangle((int)this.rectangleFLine.X, (int)this.rectangleFLine.Y, (int)this.rectangleFLine.Width, (int)this.rectangleFLine.Height));
- pen.Dispose();
- //显示辅助线像素长度
- SizeF sizeF = graphics.MeasureString("" + this.lineLength, new System.Drawing.Font("宋体", 20));
- graphics.DrawString("" + this.lineLength, new System.Drawing.Font("宋体", 20), new SolidBrush(Color.Black), new PointF(this.rectangleFLine.Right - sizeF.Width, this.rectangleFLine.Top - sizeF.Height));
- }
- /// <summary>
- /// 绘制辅助线(单圆辅助线)
- /// </summary>
- public void DrawGuideLines3(Graphics graphics)
- {
- // 以下为绘制样式
- Pen linePen = new Pen(Color.FromArgb(this.lineColor), this.lineWidth);
- graphics.DrawEllipse(linePen, this.rectangleFLine.X, this.rectangleFLine.Y, this.rectangleFLine.Width, this.rectangleFLine.Height);
- Pen pen = new Pen(Color.FromArgb(this.lineColor), 1);
- pen.DashStyle = DashStyle.DashDotDot;
- //使用自定义线型
- float[] dashArray = {
- 2.0f, //线长2个像素
- 5.0f, //间断5个像素
- 2.0f, //线长2个像素
- 5.0f //间断5个像素
- };
- pen.DashPattern = dashArray;
- graphics.DrawRectangle(pen, new Rectangle((int)this.rectangleFLine.X, (int)this.rectangleFLine.Y, (int)this.rectangleFLine.Width, (int)this.rectangleFLine.Height));
- pen.Dispose();
- }
- /// <summary>
- /// 绘制辅助线(三圆辅助线)
- /// </summary>
- public void DrawGuideLines4(Graphics graphics)
- {
- // 以下为绘制样式
- Pen linePen = new Pen(Color.FromArgb(this.lineColor), this.lineWidth);
- graphics.DrawEllipse(linePen, this.rectangleFLine.X, this.rectangleFLine.Y, this.rectangleFLine.Width, this.rectangleFLine.Height);
- graphics.DrawEllipse(linePen, this.rectangleFLine.X + this.mat_margin, this.rectangleFLine.Y + this.mat_margin, this.rectangleFLine.Width - 2 * this.mat_margin, this.rectangleFLine.Height - 2 * this.mat_margin);
- graphics.DrawEllipse(linePen, this.rectangleFLine.X + 2 * this.mat_margin, this.rectangleFLine.Y + 2 * this.mat_margin, this.rectangleFLine.Width - 4 * this.mat_margin, this.rectangleFLine.Height - 4 * this.mat_margin);
- Pen pen = new Pen(Color.FromArgb(this.lineColor), 1);
- pen.DashStyle = DashStyle.DashDotDot;
- //使用自定义线型
- float[] dashArray = {
- 2.0f, //线长2个像素
- 5.0f, //间断5个像素
- 2.0f, //线长2个像素
- 5.0f //间断5个像素
- };
- pen.DashPattern = dashArray;
- graphics.DrawRectangle(pen, new Rectangle((int)this.rectangleFLine.X, (int)this.rectangleFLine.Y, (int)this.rectangleFLine.Width, (int)this.rectangleFLine.Height));
- pen.Dispose();
- }
- /// <summary>
- /// 绘制辅助线(复合辅助线)
- /// </summary>
- public void DrawGuideLines5(Graphics graphics)
- {
- // 以下为绘制样式
- Pen linePen = new Pen(Color.FromArgb(this.lineColor), this.lineWidth);
- graphics.DrawLine(linePen,
- new PointF(this.rectangleFLine.X, this.rectangleFLine.Y + this.rectangleFLine.Height / 2 - this.mat_HLineToCDistance / 2 - this.mat_vLineLength / 2)
- , new PointF(this.rectangleFLine.X, this.rectangleFLine.Y + this.rectangleFLine.Height / 2 - this.mat_HLineToCDistance / 2 + this.mat_vLineLength / 2));
- graphics.DrawLine(linePen,
- new PointF(this.rectangleFLine.X + this.rectangleFLine.Width / 2 + this.mat_VLineToCDistance / 2 - this.mat_hLineLength / 2, this.rectangleFLine.Bottom)
- , new PointF(this.rectangleFLine.X + this.rectangleFLine.Width / 2 + this.mat_VLineToCDistance / 2 + this.mat_hLineLength / 2, this.rectangleFLine.Bottom));
- // 圆心
- Point center = new Point((int)(this.rectangleFLine.X + this.rectangleFLine.Width / 2 + this.mat_VLineToCDistance / 2), (int)(this.rectangleFLine.Y + this.rectangleFLine.Height / 2 - this.mat_HLineToCDistance / 2));
- double len = System.Math.Sqrt(((this.mat_ToprightLineLength / 2) * (this.mat_ToprightLineLength / 2)) / 2);
- // 左下到右上斜线
- Point a = new Point((int)center.X - (int)len, (int)center.Y + (int)len);
- Point b = new Point((int)center.X + (int)len, (int)center.Y - (int)len);
- graphics.DrawLine(linePen, a, b);
- len = System.Math.Sqrt(((this.mat_TopleftLineLength / 2) * (this.mat_TopleftLineLength / 2)) / 2);
- // 左上到右下斜线
- a = new Point((int)center.X - (int)len, (int)center.Y - (int)len);
- b = new Point((int)center.X + (int)len, (int)center.Y + (int)len);
- graphics.DrawLine(linePen, a, b);
- graphics.DrawEllipse(linePen, center.X - this.mat_diameter / 2, center.Y - this.mat_diameter / 2, this.mat_diameter, this.mat_diameter);
- graphics.DrawEllipse(linePen, center.X - this.mat_diameter / 2 - this.mat_margin, center.Y - this.mat_diameter / 2 - this.mat_margin, this.mat_diameter + 2 * this.mat_margin, this.mat_diameter + 2 * this.mat_margin);
- graphics.DrawEllipse(linePen, center.X - this.mat_diameter / 2 - 2 * this.mat_margin, center.Y - this.mat_diameter / 2 - 2 * this.mat_margin, this.mat_diameter + 4 * this.mat_margin, this.mat_diameter + 4 * this.mat_margin);
- Pen pen = new Pen(Color.FromArgb(this.lineColor), 1);
- pen.DashStyle = DashStyle.DashDotDot;
- //使用自定义线型
- float[] dashArray = {
- 2.0f, //线长2个像素
- 5.0f, //间断5个像素
- 2.0f, //线长2个像素
- 5.0f //间断5个像素
- };
- pen.DashPattern = dashArray;
- graphics.DrawRectangle(pen, new Rectangle((int)this.rectangleFLine.X, (int)this.rectangleFLine.Y, (int)this.rectangleFLine.Width, (int)this.rectangleFLine.Height));
- pen.Dispose();
- }
- /// <summary>
- /// 切换辅助线时控制缩放比例避免超出当前图片(垂直辅助线)
- /// </summary>
- /// <param name="multiple">放大倍数</param>
- /// <param name="physical_Micron">标尺</param>
- /// <param name="rGuideStyle">配置文件rGuideStyle</param>
- public void updateWithGuideModel1(double multiple, double physical_Micron, float recWidth)
- {
- if (recWidth == -1)
- {//###
- this.mat_lineLength = this.rectangleFLine.Height;
- this.lineLength = (int)(this.mat_lineLength * physical_Micron);
- this.mat_lineSpacing = (int)(this.rectangleFLine.Width / System.Math.Max(1, this.lineDec - 1));
- return;
- }
- this.lineLength = (int)(multiple * this.lineLength);
- this.mat_lineLength = (float)(this.lineLength / physical_Micron);
- this.originMat_lineSpacing = this.originLineSpacing / physical_Micron;
- this.mat_lineSpacing = (int)(multiple * recWidth / System.Math.Max(1, this.lineDec - 1));
- }
- /// <summary>
- /// 切换辅助线时控制缩放比例避免超出当前图片(水平辅助线)
- /// </summary>
- /// <param name="multiple">放大倍数</param>
- /// <param name="physical_Micron">标尺</param>
- /// <param name="rGuideStyle">配置文件rGuideStyle</param>
- public void updateWithGuideModel2(double multiple, double physical_Micron, float recHeight)
- {
- if (recHeight == -1)
- {//###
- this.mat_lineLength = this.rectangleFLine.Width;
- this.lineLength = (int)(this.mat_lineLength * physical_Micron);
- this.mat_lineSpacing = (int)(this.rectangleFLine.Height / System.Math.Max(1, this.lineDec - 1));
- return;
- }
- this.lineLength = (int)(multiple * this.lineLength);
- this.mat_lineLength = (float)(this.lineLength / physical_Micron);
- this.originMat_lineSpacing = this.originLineSpacing / physical_Micron;
- this.mat_lineSpacing = (int)(multiple * recHeight / System.Math.Max(1, this.lineDec - 1));
- }
- /// <summary>
- /// 切换辅助线时控制缩放比例避免超出当前图片(单圆辅助线)
- /// </summary>
- /// <param name="multiple">放大倍数</param>
- /// <param name="physical_Micron">标尺</param>
- /// <param name="rGuideStyle">配置文件rGuideStyle</param>
- public void updateWithGuideModel3(double multiple, double physical_Micron, bool moving = false)
- {
- if (moving)
- {
- this.diameter = multiple * this.originDiameter;
- this.mat_diameter = (int)(this.diameter / physical_Micron);
- return;
- }
- this.diameter = (double)(multiple * this.diameter);
- this.mat_diameter = (float)(this.diameter / physical_Micron);
- ////###
- //this.diameter = multiple * this.originDiameter;
- //this.mat_diameter = (int)(this.diameter / physical_Micron);
- }
- /// <summary>
- /// 切换辅助线时控制缩放比例避免超出当前图片(三圆辅助线)
- /// </summary>
- /// <param name="multiple">放大倍数</param>
- /// <param name="physical_Micron">标尺</param>
- /// <param name="rGuideStyle">配置文件rGuideStyle</param>
- public void updateWithGuideModel4(double multiple, double physical_Micron, bool moving = false)
- {
- if (moving)
- {
- this.diameter = multiple * this.originDiameter;
- this.mat_diameter = (int)(this.diameter / physical_Micron);
- this.margin = multiple * this.originMargin;
- this.mat_margin = (int)(this.margin / physical_Micron);
- return;
- }
- this.diameter = (double)(multiple * this.diameter);
- this.mat_diameter = (float)(this.diameter / physical_Micron);
- this.margin = (double)(multiple * this.margin);
- this.mat_margin = (float)(this.margin / physical_Micron);
- ////###
- //this.diameter = multiple * this.originDiameter;
- //this.mat_diameter = (int)(this.diameter / physical_Micron);
- //this.margin = multiple * this.originMargin;
- //this.mat_margin = (int)(this.margin / physical_Micron);
- }
- /// <summary>
- /// 切换辅助线时控制缩放比例避免超出当前图片(复合辅助线)
- /// </summary>
- /// <param name="multiple">放大倍数</param>
- /// <param name="physical_Micron">标尺</param>
- /// <param name="rGuideStyle">配置文件rGuideStyle</param>
- public void updateWithGuideModel5(double multiple, double physical_Micron, bool moving = false)
- {
- if (moving)
- {
- this.vLineLength = (int)(multiple * this.originVLineLength);
- this.mat_vLineLength = (int)(this.vLineLength / physical_Micron);
- this.hLineLength = (int)(multiple * this.originHLineLength);
- this.mat_hLineLength = (int)(this.hLineLength / physical_Micron);
- this.diameter = multiple * this.originDiameter;
- this.mat_diameter = (int)(this.diameter / physical_Micron);
- this.margin = multiple * this.originMargin;
- this.mat_margin = (int)(this.margin / physical_Micron);
- this.TopleftLineLength = (int)(multiple * this.originTopleftLineLength);
- this.mat_TopleftLineLength = (int)(this.TopleftLineLength / physical_Micron);
- this.ToprightLineLength = (int)(multiple * this.originToprightLineLength);
- this.mat_ToprightLineLength = (int)(this.ToprightLineLength / physical_Micron);
- this.VLineToCDistance = (int)(multiple * this.originVLineToCDistance);
- this.mat_VLineToCDistance = (int)(this.VLineToCDistance / physical_Micron);
- this.HLineToCDistance = (int)(multiple * this.originHLineToCDistance);
- this.mat_HLineToCDistance = (int)(this.HLineToCDistance / physical_Micron);
- return;
- }
- this.vLineLength = (int)(multiple * this.vLineLength);
- this.mat_vLineLength = (float)(this.vLineLength / physical_Micron);
- this.hLineLength = (int)(multiple * this.hLineLength);
- this.mat_hLineLength = (float)(this.hLineLength / physical_Micron);
- this.diameter = (double)(multiple * this.diameter);
- this.mat_diameter = (float)(this.diameter / physical_Micron);
- this.margin = (double)(multiple * this.margin);
- this.mat_margin = (float)(this.margin / physical_Micron);
- this.TopleftLineLength = (int)(multiple * this.TopleftLineLength);
- this.mat_TopleftLineLength = (float)(this.TopleftLineLength / physical_Micron);
- this.ToprightLineLength = (int)(multiple * this.ToprightLineLength);
- this.mat_ToprightLineLength = (float)(this.ToprightLineLength / physical_Micron);
- this.VLineToCDistance = (float)(multiple * this.VLineToCDistance);
- this.HLineToCDistance = (float)(multiple * this.HLineToCDistance);
- this.mat_VLineToCDistance = (float)(this.VLineToCDistance / physical_Micron);
- this.mat_HLineToCDistance = (float)(this.HLineToCDistance / physical_Micron);
- ////###
- //this.vLineLength = (int)(multiple * this.originVLineLength);
- //this.mat_vLineLength = (int)(this.vLineLength / physical_Micron);
- //this.hLineLength = (int)(multiple * this.originHLineLength);
- //this.mat_hLineLength = (int)(this.hLineLength / physical_Micron);
- //this.diameter = multiple * this.originDiameter;
- //this.mat_diameter = (int)(this.diameter / physical_Micron);
- //this.margin = multiple * this.originMargin;
- //this.mat_margin = (int)(this.margin / physical_Micron);
- //this.TopleftLineLength = (int)(multiple * this.originTopleftLineLength);
- //this.mat_TopleftLineLength = (int)(this.TopleftLineLength / physical_Micron);
- //this.ToprightLineLength = (int)(multiple * this.originToprightLineLength);
- //this.mat_ToprightLineLength = (int)(this.ToprightLineLength / physical_Micron);
- //this.VLineToCDistance = (int)(multiple * this.originVLineToCDistance);
- //this.mat_VLineToCDistance = (int)(this.VLineToCDistance / physical_Micron);
- //this.HLineToCDistance = (int)(multiple * this.originHLineToCDistance);
- //this.mat_HLineToCDistance = (int)(this.HLineToCDistance / physical_Micron);
- }
- /// <summary>
- /// 通过配置文件rGuideStyle给model赋值(垂直辅助线)
- /// </summary>
- /// <param name="multiple">放大倍数</param>
- /// <param name="physical_Micron">标尺</param>
- /// <param name="rGuideStyle">配置文件rGuideStyle</param>
- public void initWithGrainRGuideStyle1(double multiple, double physical_Micron, GrainSizeGuideStyleModel.VGuideStyle vGuideStyle)
- {
- this.originLineLength = 1/*multiple*/ * vGuideStyle.lineLength;
- this.lineLength = (int)(multiple * vGuideStyle.lineLength);
- this.mat_lineLength = (int)(multiple * vGuideStyle.lineLength / physical_Micron);
- this.originLineSpacing = 1/*multiple*/ * vGuideStyle.lineSpacing;
- this.originMat_lineSpacing = 1/*multiple*/ * vGuideStyle.lineSpacing / physical_Micron;
- this.mat_lineSpacing = (int)(multiple * vGuideStyle.lineSpacing / physical_Micron);
- this.lineDec = vGuideStyle.lineDec;
- this.lineColor = vGuideStyle.lineColor;
- this.lineWidth = vGuideStyle.lineWidth;
- }
- /// <summary>
- /// 通过配置文件rGuideStyle给model赋值(水平辅助线)
- /// </summary>
- /// <param name="multiple">放大倍数</param>
- /// <param name="physical_Micron">标尺</param>
- /// <param name="rGuideStyle">配置文件rGuideStyle</param>
- public void initWithGrainRGuideStyle2(double multiple, double physical_Micron, GrainSizeGuideStyleModel.HGuideStyle hGuideStyle)
- {
- this.originLineLength = 1/*multiple*/ * hGuideStyle.lineLength;
- this.lineLength = (int)(multiple * hGuideStyle.lineLength);
- this.mat_lineLength = (int)(multiple * hGuideStyle.lineLength / physical_Micron);
- this.originLineSpacing = 1/*multiple*/ * hGuideStyle.lineSpacing;
- this.originMat_lineSpacing = 1/*multiple*/ * hGuideStyle.lineSpacing / physical_Micron;
- this.mat_lineSpacing = (int)(multiple * hGuideStyle.lineSpacing / physical_Micron);
- this.lineDec = hGuideStyle.lineDec;
- this.lineColor = hGuideStyle.lineColor;
- this.lineWidth = hGuideStyle.lineWidth;
- }
- /// <summary>
- /// 通过配置文件rGuideStyle给model赋值(单圆辅助线)
- /// </summary>
- /// <param name="multiple">放大倍数</param>
- /// <param name="physical_Micron">标尺</param>
- /// <param name="rGuideStyle">配置文件rGuideStyle</param>
- public void initWithGrainRGuideStyle3(double multiple, double physical_Micron, GrainSizeGuideStyleModel.CGuideStyle cGuideStyle)
- {
- this.originDiameter = 1/*multiple*/ * cGuideStyle.diameter;
- this.diameter = multiple * cGuideStyle.diameter;
- this.mat_diameter = (int)(multiple * cGuideStyle.diameter / physical_Micron);
- this.lineColor = cGuideStyle.lineColor;
- this.lineWidth = cGuideStyle.lineWidth;
- }
- /// <summary>
- /// 通过配置文件rGuideStyle给model赋值(三圆辅助线)
- /// </summary>
- /// <param name="multiple">放大倍数</param>
- /// <param name="physical_Micron">标尺</param>
- /// <param name="rGuideStyle">配置文件rGuideStyle</param>
- public void initWithGrainRGuideStyle4(double multiple, double physical_Micron, GrainSizeGuideStyleModel.TCGuideStyle tCGuideStyle)
- {
- this.originDiameter = 1/*multiple*/ * tCGuideStyle.diameter;
- this.diameter = multiple * tCGuideStyle.diameter;
- this.mat_diameter = (int)(multiple * tCGuideStyle.diameter / physical_Micron);
- this.originMargin = 1/*multiple*/ * tCGuideStyle.margin;
- this.margin = multiple * tCGuideStyle.margin;
- this.mat_margin = (int)(multiple * tCGuideStyle.margin / physical_Micron);
- this.lineColor = tCGuideStyle.lineColor;
- this.lineWidth = tCGuideStyle.lineWidth;
- }
- /// <summary>
- /// 通过配置文件rGuideStyle给model赋值(复合辅助线)
- /// </summary>
- /// <param name="multiple">放大倍数</param>
- /// <param name="physical_Micron">标尺</param>
- /// <param name="rGuideStyle">配置文件rGuideStyle</param>
- public void initWithGrainRGuideStyle5(double multiple, double physical_Micron, GrainSizeGuideStyleModel.RGuideStyle rGuideStyle)
- {
- this.originVLineLength = 1/*multiple*/ * rGuideStyle.vLineLength;
- this.vLineLength = (int)(multiple * rGuideStyle.vLineLength);
- this.mat_vLineLength = (int)(multiple * rGuideStyle.vLineLength / physical_Micron);
- this.originHLineLength = 1/*multiple*/ * rGuideStyle.hLineLength;
- this.hLineLength = (int)(multiple * rGuideStyle.hLineLength);
- this.mat_hLineLength = (int)(multiple * rGuideStyle.hLineLength / physical_Micron);
- this.originDiameter = 1/*multiple*/ * rGuideStyle.diameter;
- this.diameter = multiple * rGuideStyle.diameter;
- this.mat_diameter = (int)(multiple * rGuideStyle.diameter / physical_Micron);
- this.originMargin = 1/*multiple*/ * rGuideStyle.margin;
- this.margin = multiple * rGuideStyle.margin;
- this.mat_margin = (int)(multiple * rGuideStyle.margin / physical_Micron);
- this.originTopleftLineLength = 1/*multiple*/ * rGuideStyle.TopleftLineLength;
- this.TopleftLineLength = (int)(multiple * rGuideStyle.TopleftLineLength);
- this.mat_TopleftLineLength = (int)(multiple * rGuideStyle.TopleftLineLength / physical_Micron);
- this.originToprightLineLength = 1/*multiple*/ * rGuideStyle.ToprightLineLength;
- this.ToprightLineLength = (int)(multiple * rGuideStyle.ToprightLineLength);
- this.mat_ToprightLineLength = (int)(multiple * rGuideStyle.ToprightLineLength / physical_Micron);
- this.originVLineToCDistance = 1/*multiple*/ * rGuideStyle.VLineToCDistance;
- this.VLineToCDistance = (int)(multiple * rGuideStyle.VLineToCDistance);
- this.mat_VLineToCDistance = (int)(multiple * rGuideStyle.VLineToCDistance / physical_Micron);
- this.originHLineToCDistance = 1/*multiple*/ * rGuideStyle.HLineToCDistance;
- this.HLineToCDistance = (int)(multiple * rGuideStyle.HLineToCDistance);
- this.mat_HLineToCDistance = (int)(multiple * rGuideStyle.HLineToCDistance / physical_Micron);
- this.lineColor = rGuideStyle.lineColor;
- this.lineWidth = rGuideStyle.lineWidth;
- }
- }
- }
|