1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- /**
- *
- * @author seagle
- * @date 2024-7-22
- * @Description 管路图元件对象封装
- */
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace MECF.Framework.UI.Core.DxfScript
- {
- public class GasPolyLine:GasBaseShape
- {
- public List<GasLine> InnerLines { get; set; } = null;
- public GasPolyLine()
- {
- InnerLines = new List<GasLine>();
- }
- public void AddLine(GasLine line)
- {
- InnerLines.Add(line);
- }
- //PolyLine的Id取所有线段最左上坐标需要外部调用此函数设置
- public int CreateId()
- {
- double xMin = 1999;
- double yMax = -1999;
- foreach(GasLine line in InnerLines)
- {
- double xx, yy;
- xx = Math.Min(line.X1, line.X2);
- yy = Math.Max(line.Y1, line.Y2);
- if (xx < xMin)
- {
- xMin = xx;
- }
- if (yy > yMax)
- {
- yMax = yy;
- }
- }
- Id = CreateId(ShapeType.POLY, xMin, yMax);
- return Id;
- }
- public override bool Contains(double x, double y)
- {
- double xMin = 1999;
- double xMax = -1999;
- double yMin = 1999;
- double yMax = -1999;
-
- foreach (GasLine line in InnerLines)
- {
- double xxMin,xxMax,yyMin,yyMax;
- xxMin = Math.Min(line.X1, line.X2);
- xxMax = Math.Max(line.X1, line.X2);
- yyMin = Math.Min(line.Y1, line.Y2);
- yyMax = Math.Max(line.Y1, line.Y2);
- if (xxMin < xMin)
- {
- xMin = xxMin;
- }
- if (xxMax > xMax)
- {
- xMax = xxMax;
- }
- if (yyMin< yMin)
- {
- yMin = yyMin;
- }
- if (yyMax > yMax)
- {
- yMax = yyMax;
- }
- }
- if(x>=xMin-E && x<=xMax+E && y>=yMin-E && y <= yMax + E)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- public override void Move(double x, double y)
- {
- foreach(GasLine line in InnerLines)
- {
- line.Move(x, y);
- }
- }
- }
- }
|