private void DoAndUpdateMinSignalDelay() { (int minSignalDelaySteps, WirePoint minSignalDelayPoint) = _crossedWiresResolver.MinSignalDelay(WirePaths, WirePointIntersections); _minSignalDelaySteps = minSignalDelaySteps; _minSignalDelayPoint = minSignalDelayPoint; }
private Rectangle CalculateWireBoxing() { if (_box == null) { // Iterate through var tempBox = new Rectangle(); var currentPosition = new WirePoint(0, 0); foreach (var step in this) { (WirePoint newPosition, _) = UpdatePositionWithStep(step, currentPosition); tempBox.AdjustDimensionToIncludePoint(newPosition); currentPosition = newPosition; } _box = tempBox; } return(_box); }
private List <WirePoint> GenerateWirePoints() { if (_wirePoints == null) { // Iterate through var tempPoints = new List <WirePoint>(); var currentPosition = new WirePoint(0, 0); //tempPoints.Add(new WirePoint(currentPosition, panelSteps++)); foreach (var wireCode in this) { (WirePoint newPosition, List <WirePoint> newPoints) = UpdatePositionWithStep(wireCode, currentPosition); tempPoints.AddRange(newPoints); currentPosition = newPosition; } _wirePoints = tempPoints; } return(_wirePoints); }
public (int minSignalDelaySteps, WirePoint minSignalDelayPoint) MinSignalDelay(IReadOnlyList <WirePath> wirePaths, List <WirePoint> intersectionsWirePoints) { //// Array to keep the steps for each //int[,] wiresSteps = new int[wirePaths.Count,intersections.Count]; var crossedWirePoints = new List <WirePoint>(); foreach (var point in intersectionsWirePoints) { crossedWirePoints.Add(new WirePoint(point.X, point.Y, true, 0)); } foreach (var crossedPoint in crossedWirePoints) { foreach (var wire in wirePaths) { var commonPoints = wire.WirePoints.FindAll(p => p.X == crossedPoint.X && p.Y == crossedPoint.Y); if (commonPoints.Any()) { var minimumSteps = commonPoints.Min(p => p.Steps); crossedPoint.Steps += minimumSteps; } } } WirePoint minSignalDelayPoint = null; foreach (var crossedPoint in crossedWirePoints) { if (minSignalDelayPoint == null) { minSignalDelayPoint = crossedPoint; } else { if (crossedPoint.Steps < minSignalDelayPoint.Steps) { minSignalDelayPoint = crossedPoint; } } } return(minSignalDelayPoint.Steps, minSignalDelayPoint); }
//TODO-JOAO-REMOVE #if false private List <WirePoint> GenerateWirePoints2() { if (_wirePoints == null) { // Iterate through var tempPoints = new List <WirePoint>(); var currentPosition = new WirePoint(0, 0); int panelSteps = 0; //tempPoints.Add(new WirePoint(currentPosition, panelSteps++)); foreach (var wireCode in this) { (int steps, WirePoint newPosition) = UpdatePositionWithStep(wireCode, currentPosition); if (currentPosition.X == newPosition.X) { int y = currentPosition.Y + 1; int increment = (steps > 0) ? +1 : -1; while (steps != 0) { var wirePoint = new WirePoint(newPosition.X, y, false, panelSteps++); tempPoints.Add(wirePoint); steps -= increment; y += increment; } } else { int x = currentPosition.X + 1; int increment = (steps > 0) ? +1 : -1; while (steps != 0) { var wirePoint = new WirePoint(x, newPosition.Y, false, panelSteps++); tempPoints.Add(wirePoint); steps -= increment; x += increment; } } currentPosition = newPosition; } _wirePoints = tempPoints; } return(_wirePoints); }
public List <WirePoint> FindIntersectionPoints(IReadOnlyList <WirePath> wirePaths) { var crossedWirePoints = new List <WirePoint>(); if (wirePaths.Count > 1) { for (int wirePathIndex1 = 0; wirePathIndex1 < wirePaths.Count - 1; wirePathIndex1++) { var firstWirePoints = wirePaths[wirePathIndex1].WirePoints; for (int wirePathIndex2 = wirePathIndex1 + 1; wirePathIndex2 < wirePaths.Count; wirePathIndex2++) { var secondWirePoints = wirePaths[wirePathIndex2].WirePoints; foreach (var wpt1 in firstWirePoints) { foreach (var wpt2 in secondWirePoints) { if (!wpt1.AreSameCoordinate(wpt2)) { continue; } wpt1.IsCrossed = true; wpt2.IsCrossed = true; WirePoint wptWithMinSteps = wpt1.Steps < wpt2.Steps ? wpt1 : wpt2; var existingWirePoint = crossedWirePoints.Find(p => p.AreSameCoordinate(wpt1)); if (existingWirePoint == null) { // Add the new crossed wire point. crossedWirePoints.Add(new WirePoint(wptWithMinSteps)); } else { // Update the existing node with the minimum of steps existingWirePoint.Steps = Math.Min(existingWirePoint.Steps, wptWithMinSteps.Steps); } } } } } } return(crossedWirePoints); }
/// <summary> /// 根据点坐标绘制点要素 /// </summary> /// <params name="featureLayer"></params> /// <params name="point"></params> /// <params name="id"></params> /// <params name="wirePoint"></params> public void CreatePoint(IFeatureLayer featureLayer, IPoint point, string id, WirePoint wirePoint) { try { IFeatureClass featureClass = featureLayer.FeatureClass; IGeometry geometry = point; if (featureClass.ShapeType == esriGeometryType.esriGeometryPoint) { IDataset dataset = (IDataset)featureClass; IWorkspace workspace = dataset.Workspace; IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit; DataEditCommon.CheckEditState(); workspaceEdit.StartEditOperation(); IFeature feature = featureClass.CreateFeature(); DrawCommon.HandleZMValue(feature, geometry);//几何图形Z值处理 feature.Shape = point; feature.Value[feature.Fields.FindField(GIS_Const.FIELD_BID)] = id; feature.Value[feature.Fields.FindField(GIS_Const.FIELD_HDID)] = wirePoint.wire.tunnel.id; feature.Value[feature.Fields.FindField(GIS_Const.FIELD_NAME)] = wirePoint.name; feature.Value[feature.Fields.FindField(GIS_Const.FIELD_ID)] = wirePoint.id; feature.Store(); workspaceEdit.StopEditOperation(); IEnvelope envelop = point.Envelope; DataEditCommon.g_pMyMapCtrl.ActiveView.Extent = envelop; DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null); } else { MessageBox.Show(@"请选择点图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch { return; } }
/// <summary> /// 构造方法 /// </summary> /// <params name="wire"></params> public WireInfoEntering(Wire wire) { // 初始化主窗体变量 Wire = wire; InitializeComponent(); // 加载需要修改的导线数据 var wirePoints = WirePoint.FindAllByProperty("wire.id", wire.id); if (wirePoints.Length > 0) { for (var i = 0; i < wirePoints.Length; i++) { dgrdvWire.Rows.Add(); dgrdvWire[0, i].Value = wirePoints[i].name; dgrdvWire[1, i].Value = wirePoints[i].coordinate_x; dgrdvWire[2, i].Value = wirePoints[i].coordinate_y; dgrdvWire[3, i].Value = wirePoints[i].coordinate_z; dgrdvWire[4, i].Value = wirePoints[i].left_distance; dgrdvWire[5, i].Value = wirePoints[i].right_distance; dgrdvWire[6, i].Value = wirePoints[i].top_distance; dgrdvWire[7, i].Value = wirePoints[i].bottom_distance; } } txtWireName.Text = wire.name; txtWireLevel.Text = wire.level; dtpMeasureDate.Value = wire.measure_date; cboVobserver.Text = wire.observer; cboVobserver.Text = wire.observer; cboCounter.Text = wire.counter; cboCounter.Text = wire.counter; dtpCountDate.Value = wire.count_date; cboChecker.Text = wire.checker; cboChecker.Text = wire.checker; dtpCheckDate.Value = wire.check_date; }
/// <summary> /// 验证 /// </summary> /// <returns></returns> private bool check() { // 判断导线点编号是否入力 if (dgrdvWire.Rows.Count - 1 == 0) { Alert.alert(Const.MSG_PLEASE_TYPE_IN + Const_GM.WIRE_POINT_ID + Const.SIGN_EXCLAMATION_MARK); return(false); } //dgrdvWire内部判断 for (var i = 0; i < dgrdvWire.RowCount; i++) { // 最后一行为空行时,跳出循环 if (i == dgrdvWire.RowCount - 1) { break; } var cell = dgrdvWire.Rows[i].Cells[0] as DataGridViewTextBoxCell; // 判断导线点编号是否入力 if (cell.Value == null) { cell.Style.BackColor = Const.ERROR_FIELD_COLOR; Alert.alert(Const_GM.WIRE_POINT_ID + Const.MSG_NOT_NULL + Const.SIGN_EXCLAMATION_MARK); return(false); } cell.Style.BackColor = Const.NO_ERROR_FIELD_COLOR; //判断导线点编号是否存在 if (Text == Const_GM.WIRE_INFO_ADD) { //导线点是否存在 if (WirePoint.ExistsByWirePointIdInWireInfo(wireEntity.WireId, dgrdvWire.Rows[i].Cells[0].Value.ToString())) { cell.Style.BackColor = Const.ERROR_FIELD_COLOR; Alert.alert(Const_GM.WIRE_POINT_ID + Const.MSG_ALREADY_HAVE + Const.SIGN_EXCLAMATION_MARK); return(false); } cell.Style.BackColor = Const.NO_ERROR_FIELD_COLOR; } //判断导线点编号是否有输入重复 for (var j = 0; j < i; j++) { if (dgrdvWire[0, j].Value.ToString() == dgrdvWire[0, i].Value.ToString()) { cell.Style.BackColor = Const.ERROR_FIELD_COLOR; dgrdvWire[0, j].Style.BackColor = Const.ERROR_FIELD_COLOR; Alert.alert(Const_GM.WIRE_POINT_ID + Const.MSG_DOUBLE_EXISTS + Const.SIGN_EXCLAMATION_MARK); return(false); } cell.Style.BackColor = Const.NO_ERROR_FIELD_COLOR; dgrdvWire[0, j].Style.BackColor = Const.NO_ERROR_FIELD_COLOR; } //判断坐标X是否入力 cell = dgrdvWire.Rows[i].Cells[1] as DataGridViewTextBoxCell; if (cell.Value == null) { cell.Style.BackColor = Const.ERROR_FIELD_COLOR; Alert.alert(Const.rowNotNull(i, Const_GM.X)); return(false); } cell.Style.BackColor = Const.NO_ERROR_FIELD_COLOR; // 判断坐标X是否为数字 if (!Validator.IsNumeric(cell.Value.ToString())) { cell.Style.BackColor = Const.ERROR_FIELD_COLOR; Alert.alert(Const.rowMustBeNumber(i, Const_GM.X)); return(false); } cell.Style.BackColor = Const.NO_ERROR_FIELD_COLOR; //判断坐标Y是否入力 cell = dgrdvWire.Rows[i].Cells[2] as DataGridViewTextBoxCell; if (cell.Value == null) { cell.Style.BackColor = Const.ERROR_FIELD_COLOR; Alert.alert(Const.rowNotNull(i, Const_GM.Y)); return(false); } cell.Style.BackColor = Const.NO_ERROR_FIELD_COLOR; // 判断坐标Y是否为数字 if (!Validator.IsNumeric(cell.Value.ToString())) { cell.Style.BackColor = Const.ERROR_FIELD_COLOR; Alert.alert(Const.rowMustBeNumber(i, Const_GM.Y)); return(false); } cell.Style.BackColor = Const.NO_ERROR_FIELD_COLOR; //判断坐标Z是否入力 cell = dgrdvWire.Rows[i].Cells[3] as DataGridViewTextBoxCell; if (cell.Value == null) { cell.Style.BackColor = Const.ERROR_FIELD_COLOR; Alert.alert(Const.rowNotNull(i, Const_GM.Z)); return(false); } cell.Style.BackColor = Const.NO_ERROR_FIELD_COLOR; // 判断坐标Z是否为数字 if (!Validator.IsNumeric(cell.Value.ToString())) { cell.Style.BackColor = Const.ERROR_FIELD_COLOR; Alert.alert(Const.rowMustBeNumber(i, Const_GM.Z)); return(false); } cell.Style.BackColor = Const.NO_ERROR_FIELD_COLOR; //判断距左帮距离是否入力 cell = dgrdvWire.Rows[i].Cells[4] as DataGridViewTextBoxCell; if (cell.Value == null) { cell.Style.BackColor = Const.ERROR_FIELD_COLOR; Alert.alert(Const.rowNotNull(i, Const_GM.DISTANCE_TO_LEFT)); return(false); } cell.Style.BackColor = Const.NO_ERROR_FIELD_COLOR; // 判断距左帮距离是否为数字 if (!Validator.IsNumeric(cell.Value.ToString())) { cell.Style.BackColor = Const.ERROR_FIELD_COLOR; Alert.alert(Const.rowMustBeNumber(i, Const_GM.DISTANCE_TO_LEFT)); return(false); } cell.Style.BackColor = Const.NO_ERROR_FIELD_COLOR; //判断距右帮距离是否入力 cell = dgrdvWire.Rows[i].Cells[5] as DataGridViewTextBoxCell; if (cell.Value == null) { cell.Style.BackColor = Const.ERROR_FIELD_COLOR; Alert.alert(Const.rowNotNull(i, Const_GM.DISTANCE_TO_RIGHT)); return(false); } cell.Style.BackColor = Const.NO_ERROR_FIELD_COLOR; // 判断距右帮距离是否为数字 if (!Validator.IsNumeric(cell.Value.ToString())) { cell.Style.BackColor = Const.ERROR_FIELD_COLOR; Alert.alert(Const.rowMustBeNumber(i, Const_GM.DISTANCE_TO_RIGHT)); return(false); } cell.Style.BackColor = Const.NO_ERROR_FIELD_COLOR; cell = dgrdvWire.Rows[i].Cells[6] as DataGridViewTextBoxCell; // 判断距顶板距离是否为数字 if (cell.Value != null && !Validator.IsNumeric(cell.Value.ToString())) { cell.Style.BackColor = Const.ERROR_FIELD_COLOR; Alert.alert(Const.rowMustBeNumber(i, Const_GM.DISTANCE_TO_TOP)); return(false); } cell.Style.BackColor = Const.NO_ERROR_FIELD_COLOR; cell = dgrdvWire.Rows[i].Cells[7] as DataGridViewTextBoxCell; // 判断距底板距离是否为数字 if (cell.Value != null && !Validator.IsNumeric(cell.Value.ToString())) { cell.Style.BackColor = Const.ERROR_FIELD_COLOR; Alert.alert(Const.rowMustBeNumber(i, Const_GM.DISTANCE_TO_BOTTOM)); return(false); } cell.Style.BackColor = Const.NO_ERROR_FIELD_COLOR; } //验证成功 return(true); }
private (WirePoint newPosition, List <WirePoint> newPoints) UpdatePositionWithStep(string wireCode, WirePoint currentPosition) { var newPoints = new List <WirePoint>(); var pathOrientation = wireCode[0].ToString().ToUpper(); var steps = int.Parse(wireCode.Substring(1, wireCode.Length - 1)); //var newPosition = new WirePoint(currentPosition); int delta; var currentSteps = currentPosition.Steps; switch (pathOrientation) { case "D": { delta = currentPosition.Y - steps; for (int dy = currentPosition.Y - 1; dy >= delta; dy--) { var wirePoint = new WirePoint(currentPosition.X, dy, false, ++currentSteps); newPoints.Add(wirePoint); } break; } case "U": { delta = currentPosition.Y + steps; for (int dy = currentPosition.Y + 1; dy <= delta; dy++) { var wirePoint = new WirePoint(currentPosition.X, dy, false, ++currentSteps); newPoints.Add(wirePoint); } break; } case "L": { delta = currentPosition.X - steps; for (int dx = currentPosition.X - 1; dx >= delta; dx--) { var wirePoint = new WirePoint(dx, currentPosition.Y, false, ++currentSteps); newPoints.Add(wirePoint); } break; } case "R": { delta = currentPosition.X + steps; for (int dx = currentPosition.X + 1; dx <= delta; dx++) { var wirePoint = new WirePoint(dx, currentPosition.Y, false, ++currentSteps); newPoints.Add(wirePoint); } break; } default: throw new InvalidOperationException( $"Unknown orientation '{pathOrientation}' [Step: '{wireCode}'] [Increment: '{steps}']."); } return(newPoints.Last(), newPoints); }
private void CircuitView_MouseDown(object sender, MouseEventArgs e) { Gate g = GateOn(e.Location); Dot d = DotOn(e.Location); WirePoint wp = WirePointOn(e.Location); Wire wire = WireOn(e.Location); if (Simulating) { if (g != null) { Point rotatedPoint = RotatePoint(e.Location, g.Location, -g.Angle); MouseEventArgs eventArgs = new MouseEventArgs( e.Button, e.Clicks, rotatedPoint.X, rotatedPoint.Y, e.Delta); g.MouseDown(eventArgs); } return; } if (d == null && g == null && wp == null && wire == null) { ModifySelection(true, true, false); if (OnGateSelected != null) { OnGateSelected(null); } RedrawGates(); } if (d != null) { Dot_MouseDown(d, e.Location); } else { if (g != null) { Gate_MouseDown(g, e.Location); } else { if (wp != null) { selectedWP = wp; } else { if (wire != null) { Wire_MouseDown(wire); } else { MouseDownPosition = e.Location; selectionRectangle = new Rectangle(e.Location, Size.Empty); } } } } }
/// <summary> /// 计算仅含两个导线点的巷道的左右邦点 /// </summary> /// <params name="wirePts"></params> /// <params name="verticesLeftRet"></params> /// <params name="verticesRightRet"></params> /// <returns></returns> private bool calc_left_and_right_vertics_with2_traver_points(WirePoint[] wirePts, ref Vector3_DW[] verticesLeftRet, ref Vector3_DW[] verticesRightRet) { if (wirePts == null) { return false; } int nTraversePtCnt = wirePts.Length; if (nTraversePtCnt != 2) { return false; } //仅含两个导线点 if (nTraversePtCnt == 2) { var ptPre = new Vector2_DW(wirePts[0].coordinate_x, wirePts[0].coordinate_y); var ptNext = new Vector2_DW(wirePts[1].coordinate_x, wirePts[1].coordinate_y); Vector2_DW vecForwardDir = (ptNext - ptPre).Normalize(); /*根据法线方向判断巷道左右邦. * 若垂直向量vecPerpendicular与vecForwardDir的叉积所得向量与Y轴夹角小于90度(二者点积大于0),,则认为该垂直向量为左帮方向 * x1*x2 + y1*y2 = 0//垂直 * x1*y2 - x2*y1 = 0//平行 * *点积 a●b=|a|*|b|*cos(w)=x1*x2+y1*y2=0 *叉积 aXb=|a|*|b|*sin(w)=(x1*z2-z1*y2)x^+(z1*x2-z1*y2)y^+(x1*y2-y1*x2)z^(右手螺旋定则)=0 -->二维的表示平行四边形的面积 *混合积 (aXb)●c = |aXb|*|c|*cos(aXb,c) -->平行六面体的体积 */ var vecPerpendicularLeft = new Vector2_DW(vecForwardDir.Y, -vecForwardDir.X); Vector2_DW vecPerpendicularRight = -vecPerpendicularLeft; Vector3_DW vecNormal = Vector3_DW.Cross(new Vector3_DW(vecForwardDir.X, vecForwardDir.Y, 0), new Vector3_DW(vecPerpendicularLeft.X, vecPerpendicularLeft.Y, 0)); if (vecNormal.Z < 0) { Vector2_DW vecSwap = vecPerpendicularLeft; vecPerpendicularLeft = vecPerpendicularRight; vecPerpendicularRight = vecSwap; } var leftVertices = new List<Vector3_DW>(); var rightVertices = new List<Vector3_DW>(); Vector2_DW ptLeftPre = ptPre + vecPerpendicularLeft * wirePts[0].left_distance; Vector2_DW ptLeftNext = ptNext + vecPerpendicularLeft * wirePts[1].left_distance; Vector2_DW ptRightPre = ptPre + vecPerpendicularRight * wirePts[0].right_distance; Vector2_DW ptRightNext = ptNext + vecPerpendicularRight * wirePts[1].right_distance; leftVertices.Add(new Vector3_DW(ptLeftPre.X, ptLeftPre.Y, wirePts[0].coordinate_z)); leftVertices.Add(new Vector3_DW(ptLeftNext.X, ptLeftNext.Y, wirePts[1].coordinate_z)); rightVertices.Add(new Vector3_DW(ptRightPre.X, ptRightPre.Y, wirePts[0].coordinate_z)); rightVertices.Add(new Vector3_DW(ptRightNext.X, ptRightNext.Y, wirePts[1].coordinate_z)); verticesLeftRet = leftVertices.ToArray(); verticesRightRet = rightVertices.ToArray(); } return true; }
/// <summary> /// 根据导线点计算巷道左右帮的点 /// 前后两个导线点坐标一样的情况未处理,传入的导线点数据需要保证不重复. /// </summary> /// <params name="wirePts">导线点实体</params> /// <params name="verticesLeftBtmRet">out,根据导线点计算出的巷道左帮所有点</params> /// <params name="verticesRightBtmRet">out,根据导线点计算出的巷道右帮所有点</params> /// <returns></returns> public bool calc_left_and_right_vertics(WirePoint[] wirePts, ref Vector3_DW[] verticesLeftBtmRet, ref Vector3_DW[] verticesRightBtmRet) { if (wirePts == null) { return false; } int nTraversePtCnt = wirePts.Length; if (nTraversePtCnt < 1) { return false; } #region 仅含两个导线点 if (nTraversePtCnt == 2) { bool bRet = calc_left_and_right_vertics_with2_traver_points(wirePts, ref verticesLeftBtmRet, ref verticesRightBtmRet); if (bRet == false) { return false; } } #endregion #region 大于等于三个点 else { var lstLeftBtmVertices = new List<Vector3_DW>(); var lstRightBtmVertices = new List<Vector3_DW>(); #region For loop for (int i = 0; i < nTraversePtCnt - 2; i++) { var lwDatasPreTmp = new[] { wirePts[i], wirePts[i + 1] }; var lwDatasNextTmp = new[] { wirePts[i + 1], wirePts[i + 2] }; Vector3_DW[] verticesLeftPreTmp = null; Vector3_DW[] verticesRightPreTmp = null; if (false == calc_left_and_right_vertics_with2_traver_points(lwDatasPreTmp, ref verticesLeftPreTmp, ref verticesRightPreTmp)) { return false; } Vector3_DW[] verticesLeftNextTmp = null; Vector3_DW[] verticesRightNextTmp = null; if (false == calc_left_and_right_vertics_with2_traver_points(lwDatasNextTmp, ref verticesLeftNextTmp, ref verticesRightNextTmp)) { return false; } var vertexMid2D = new Vector2_DW(); var vertexLeftMid = new Vector3_DW(); var vertexRightMid = new Vector3_DW(); //左邦中间的点 LineIntersectType lit = ToolsMath_DW.LineXLine(new Vector2_DW(verticesLeftPreTmp[0].X, verticesLeftPreTmp[0].Y), new Vector2_DW(verticesLeftPreTmp[1].X, verticesLeftPreTmp[1].Y), new Vector2_DW(verticesLeftNextTmp[0].X, verticesLeftNextTmp[0].Y), new Vector2_DW(verticesLeftNextTmp[1].X, verticesLeftNextTmp[1].Y), ref vertexMid2D); if (lit == LineIntersectType.None) //有重复点,可能是这种情况eg:p0(0, 0), p1(2, 0),p2(1, 0), p3(4, 0) { vertexLeftMid.X = verticesLeftPreTmp[1].X; vertexLeftMid.Y = verticesLeftPreTmp[1].Y; vertexLeftMid.Z = lwDatasPreTmp[1].coordinate_z; } else { vertexLeftMid.X = vertexMid2D.X; vertexLeftMid.Y = vertexMid2D.Y; vertexLeftMid.Z = lwDatasPreTmp[1].coordinate_z; } //右邦中间的点 lit = ToolsMath_DW.LineXLine(new Vector2_DW(verticesRightPreTmp[0].X, verticesRightPreTmp[0].Y), new Vector2_DW(verticesRightPreTmp[1].X, verticesRightPreTmp[1].Y), new Vector2_DW(verticesRightNextTmp[0].X, verticesRightNextTmp[0].Y), new Vector2_DW(verticesRightNextTmp[1].X, verticesRightNextTmp[1].Y), ref vertexMid2D); if (lit == LineIntersectType.None) //有重复点,可能是这种情况eg:p0(0, 0), p1(2, 0),p2(1, 0), p3(4, 0) { vertexRightMid.X = verticesRightPreTmp[1].X; vertexRightMid.Y = verticesRightPreTmp[1].Y; vertexRightMid.Z = lwDatasPreTmp[1].coordinate_z; } else { vertexRightMid.X = vertexMid2D.X; vertexRightMid.Y = vertexMid2D.Y; vertexRightMid.Z = lwDatasPreTmp[1].coordinate_z; } //保存计算出来的点 //第一个顶点 if (i == 0) { lstLeftBtmVertices.Add(verticesLeftPreTmp[0]); lstRightBtmVertices.Add(verticesRightPreTmp[0]); } //中间的顶点 lstLeftBtmVertices.Add(vertexLeftMid); lstRightBtmVertices.Add(vertexRightMid); //最后一个顶点 if (i == nTraversePtCnt - 3) { lstLeftBtmVertices.Add(verticesLeftNextTmp[1]); lstRightBtmVertices.Add(verticesRightNextTmp[1]); } } //end for #endregion verticesLeftBtmRet = lstLeftBtmVertices.ToArray(); verticesRightBtmRet = lstRightBtmVertices.ToArray(); } #endregion return true; }
private void CircuitView_MouseUp(object sender, MouseEventArgs e) { if (Simulating) { Gate g = GateOn(e.Location); if (g != null) { Point rotatedPoint = RotatePoint(e.Location, g.Location, -g.Angle); MouseEventArgs eventArgs = new MouseEventArgs( e.Button, e.Clicks, rotatedPoint.X, rotatedPoint.Y, e.Delta); g.MouseUp(eventArgs); } } isMouseDownGate = false; if (isMouseDownDot) { Dot d = DotOn(e.Location); if (d != null && selectedDot != d) { //Don't let 2 dots of the same gate connected if (d.Parent != selectedDot.Parent) { AddWire(d, selectedDot); } } isMouseDownDot = false; RedrawGates(); } if (selectionRectangle != Rectangle.Empty) { SelectComponentsInSelectionRectangle(); selectionRectangle = Rectangle.Empty; RedrawGates(); } if (e.Button == MouseButtons.Middle) { Wire wire = WireOn(e.Location); if (wire != null) { if (selectedWP != null) { wire.Points.Remove(selectedWP); } else { int idx = BeforeWirePoint(e.Location, wire); wire.Points.Insert(idx, new WirePoint(e.Location)); } RedrawGates(); } } selectedWP = null; }
/// <summary> /// 导线点实体赋值 /// </summary> /// <param name="i">Datagridview行号</param> /// <returns>导线点实体</returns> private WirePoint SetWirePointEntity(int i) { // 最后一行为空行时,跳出循环 if (i == dgrdvWire.RowCount - 1) { return(null); } // 创建导线点实体 var wirePointInfoEntity = new WirePoint(); //导线点编号 if (dgrdvWire.Rows[i].Cells[0] != null) { wirePointInfoEntity.WirePointName = dgrdvWire.Rows[i].Cells[0].Value.ToString(); } //坐标X if (dgrdvWire.Rows[i].Cells[1].Value != null) { if (double.TryParse(dgrdvWire.Rows[i].Cells[1].Value.ToString(), out _tmpDouble)) { wirePointInfoEntity.CoordinateX = _tmpDouble; _tmpDouble = 0; } } //坐标Y if (dgrdvWire.Rows[i].Cells[2].Value != null) { if (double.TryParse(dgrdvWire.Rows[i].Cells[2].Value.ToString(), out _tmpDouble)) { wirePointInfoEntity.CoordinateY = _tmpDouble; _tmpDouble = 0; } } //坐标Z if (dgrdvWire.Rows[i].Cells[3].Value != null) { if (double.TryParse(dgrdvWire.Rows[i].Cells[3].Value.ToString(), out _tmpDouble)) { wirePointInfoEntity.CoordinateZ = _tmpDouble; _tmpDouble = 0; } } //距左帮距离 if (dgrdvWire.Rows[i].Cells[4].Value != null) { if (double.TryParse(dgrdvWire.Rows[i].Cells[4].Value.ToString(), out _tmpDouble)) { wirePointInfoEntity.LeftDis = _tmpDouble; _tmpDouble = 0; } } //距右帮距离 if (dgrdvWire.Rows[i].Cells[5].Value != null) { if (double.TryParse(dgrdvWire.Rows[i].Cells[5].Value.ToString(), out _tmpDouble)) { wirePointInfoEntity.RightDis = _tmpDouble; _tmpDouble = 0; } } //距顶板距离 if (dgrdvWire.Rows[i].Cells[6].Value != null) { if (double.TryParse(dgrdvWire.Rows[i].Cells[6].Value.ToString(), out _tmpDouble)) { wirePointInfoEntity.TopDis = _tmpDouble; _tmpDouble = 0; } } //距底板距离 if (dgrdvWire.Rows[i].Cells[7].Value != null) { if (double.TryParse(dgrdvWire.Rows[i].Cells[7].Value.ToString(), out _tmpDouble)) { wirePointInfoEntity.BottomDis = _tmpDouble; _tmpDouble = 0; } } return(wirePointInfoEntity); }
/// <summary> /// ���ݵ�������Ƶ�Ҫ�� /// </summary> /// <params name="featureLayer"></params> /// <params name="point"></params> /// <params name="id"></params> /// <params name="wirePoint"></params> public void CreatePoint(IFeatureLayer featureLayer, IPoint point, string id, WirePoint wirePoint) { try { IFeatureClass featureClass = featureLayer.FeatureClass; IGeometry geometry = point; if (featureClass.ShapeType == esriGeometryType.esriGeometryPoint) { IDataset dataset = (IDataset)featureClass; IWorkspace workspace = dataset.Workspace; IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit; DataEditCommon.CheckEditState(); workspaceEdit.StartEditOperation(); IFeature feature = featureClass.CreateFeature(); DrawCommon.HandleZMValue(feature, geometry);//����ͼ��Zֵ���� feature.Shape = point; feature.Value[feature.Fields.FindField(GIS_Const.FIELD_BID)] = id; feature.Value[feature.Fields.FindField(GIS_Const.FIELD_HDID)] = wirePoint.wire.tunnel.id; feature.Value[feature.Fields.FindField(GIS_Const.FIELD_NAME)] = wirePoint.name; feature.Value[feature.Fields.FindField(GIS_Const.FIELD_ID)] = wirePoint.id; feature.Store(); workspaceEdit.StopEditOperation(); IEnvelope envelop = point.Envelope; DataEditCommon.g_pMyMapCtrl.ActiveView.Extent = envelop; DataEditCommon.g_pMyMapCtrl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null); } else { MessageBox.Show(@"��ѡ���ͼ�㡣", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch { return; } }
public bool AreSameCoordinate(WirePoint wp2) { return(X == wp2.X && Y == wp2.Y); }
/// <summary> /// 导线点实体赋值 /// </summary> /// <params name="i">Datagridview行号</params> /// <returns>导线点实体</returns> private WirePoint SetWirePointEntity(int i) { // 最后一行为空行时,跳出循环 if (i == dgrdvWire.RowCount - 1) { return(null); } // 创建导线点实体 var wirePointInfoEntity = new WirePoint(); //导线点编号 if (dgrdvWire.Rows[i].Cells[0] != null) { wirePointInfoEntity.name = dgrdvWire.Rows[i].Cells[0].Value.ToString(); } //坐标X if (dgrdvWire.Rows[i].Cells[1].Value != null) { if (double.TryParse(dgrdvWire.Rows[i].Cells[1].Value.ToString(), out _tmpDouble)) { wirePointInfoEntity.coordinate_x = _tmpDouble; _tmpDouble = 0; } } //坐标Y if (dgrdvWire.Rows[i].Cells[2].Value != null) { if (double.TryParse(dgrdvWire.Rows[i].Cells[2].Value.ToString(), out _tmpDouble)) { wirePointInfoEntity.coordinate_y = _tmpDouble; _tmpDouble = 0; } } //坐标Z if (dgrdvWire.Rows[i].Cells[3].Value != null) { if (double.TryParse(dgrdvWire.Rows[i].Cells[3].Value.ToString(), out _tmpDouble)) { wirePointInfoEntity.coordinate_z = _tmpDouble; _tmpDouble = 0; } } //距左帮距离 if (dgrdvWire.Rows[i].Cells[4].Value != null) { if (double.TryParse(dgrdvWire.Rows[i].Cells[4].Value.ToString(), out _tmpDouble)) { wirePointInfoEntity.left_distance = _tmpDouble; _tmpDouble = 0; } } //距右帮距离 if (dgrdvWire.Rows[i].Cells[5].Value != null) { if (double.TryParse(dgrdvWire.Rows[i].Cells[5].Value.ToString(), out _tmpDouble)) { wirePointInfoEntity.right_distance = _tmpDouble; _tmpDouble = 0; } } //距顶板距离 if (dgrdvWire.Rows[i].Cells[6].Value != null) { if (double.TryParse(dgrdvWire.Rows[i].Cells[6].Value.ToString(), out _tmpDouble)) { wirePointInfoEntity.top_distance = _tmpDouble; _tmpDouble = 0; } } //距底板距离 if (dgrdvWire.Rows[i].Cells[7].Value != null) { if (double.TryParse(dgrdvWire.Rows[i].Cells[7].Value.ToString(), out _tmpDouble)) { wirePointInfoEntity.bottom_distance = _tmpDouble; _tmpDouble = 0; } } return(wirePointInfoEntity); }
/// <summary> /// 构造方法 /// </summary> /// <param name="wire"></param> public WireInfoEntering(Wire wire) { // 初始化主窗体变量 Wire = wire; InitializeComponent(); // 加载需要修改的导线数据 var wirePoints = WirePoint.FindAllByWireId(wire.WireId); if (wirePoints.Length > 0) { for (var i = 0; i < wirePoints.Length; i++) { dgrdvWire.Rows.Add(); dgrdvWire[0, i].Value = wirePoints[i].WirePointName; dgrdvWire[1, i].Value = wirePoints[i].CoordinateX; dgrdvWire[2, i].Value = wirePoints[i].CoordinateY; dgrdvWire[3, i].Value = wirePoints[i].CoordinateZ; dgrdvWire[4, i].Value = wirePoints[i].LeftDis; dgrdvWire[5, i].Value = wirePoints[i].RightDis; dgrdvWire[6, i].Value = wirePoints[i].TopDis; dgrdvWire[7, i].Value = wirePoints[i].BottomDis; } } txtWireName.Text = wire.WireName; txtWireLevel.Text = wire.WireLevel; dtpMeasureDate.Value = wire.MeasureDate; cboVobserver.Text = wire.Vobserver; cboVobserver.Text = wire.Vobserver; cboCounter.Text = wire.Counter; cboCounter.Text = wire.Counter; dtpCountDate.Value = wire.CountDate; cboChecker.Text = wire.Checker; cboChecker.Text = wire.Checker; dtpCheckDate.Value = wire.CheckDate; FormDefaultPropertiesSetter.SetEnteringFormDefaultProperties(this, Const_GM.WIRE_INFO_CHANGE); //this.selectTunnelUserControl1.setCurSelectedID(_arr); // 注册委托事件 //selectTunnelUserControl1.TunnelNameChanged += // InheritTunnelNameChanged; //巷道信息赋值 //Dictionary<string, string> flds = new Dictionary<string, string>(); //flds.Add(GIS_Const.FIELD_HDID, _tunnelID.ToString()); //List<Tuple<IFeature, IGeometry, Dictionary<string, string>>> selobjs = Global.commonclss.SearchFeaturesByGeoAndText(Global.centerfdlyr, flds); //int xh = 0; //string bid = ""; //string hdname = ""; //DataSet dst=LibBusiness.TunnelInfoBLL.selectOneTunnelInfoByTunnelID(_tunnelID); //if (dst.Tables[0].Rows.Count > 0) //{ // bid = dst.Tables[0].Rows[0][LibBusiness.TunnelInfoDbConstNames.BINDINGID].ToString(); // hdname = dst.Tables[0].Rows[0][LibBusiness.TunnelInfoDbConstNames.TUNNEL_NAME].ToString(); //} //if (selobjs.Count > 0) // xh = Convert.ToInt16(selobjs[0].Item3[GIS_Const.FIELD_XH]) + 1; //dics.Clear(); //dics.Add(GIS_Const.FIELD_HDID, _tunnelID.ToString()); //dics.Add(GIS_Const.FIELD_ID, "0"); //dics.Add(GIS_Const.FIELD_BS, "1"); //dics.Add(GIS.GIS_Const.FIELD_BID, bid); //dics.Add(GIS_Const.FIELD_HDNAME, hdname); //dics.Add(GIS_Const.FIELD_XH, (xh + 1).ToString()); }
/// <summary> /// 导线点实体赋值 /// </summary> /// <params name="i">Datagridview行号</params> /// <returns>导线点实体</returns> private WirePoint SetWirePointEntity(int i) { // 最后一行为空行时,跳出循环 if (i == dgrdvWire.RowCount - 1) { return null; } // 创建导线点实体 var wirePointInfoEntity = new WirePoint(); //导线点编号 if (dgrdvWire.Rows[i].Cells[0] != null) { wirePointInfoEntity.name = dgrdvWire.Rows[i].Cells[0].Value.ToString(); } //坐标X if (dgrdvWire.Rows[i].Cells[1].Value != null) { if (double.TryParse(dgrdvWire.Rows[i].Cells[1].Value.ToString(), out _tmpDouble)) { wirePointInfoEntity.coordinate_x = _tmpDouble; _tmpDouble = 0; } } //坐标Y if (dgrdvWire.Rows[i].Cells[2].Value != null) { if (double.TryParse(dgrdvWire.Rows[i].Cells[2].Value.ToString(), out _tmpDouble)) { wirePointInfoEntity.coordinate_y = _tmpDouble; _tmpDouble = 0; } } //坐标Z if (dgrdvWire.Rows[i].Cells[3].Value != null) { if (double.TryParse(dgrdvWire.Rows[i].Cells[3].Value.ToString(), out _tmpDouble)) { wirePointInfoEntity.coordinate_z = _tmpDouble; _tmpDouble = 0; } } //距左帮距离 if (dgrdvWire.Rows[i].Cells[4].Value != null) { if (double.TryParse(dgrdvWire.Rows[i].Cells[4].Value.ToString(), out _tmpDouble)) { wirePointInfoEntity.left_distance = _tmpDouble; _tmpDouble = 0; } } //距右帮距离 if (dgrdvWire.Rows[i].Cells[5].Value != null) { if (double.TryParse(dgrdvWire.Rows[i].Cells[5].Value.ToString(), out _tmpDouble)) { wirePointInfoEntity.right_distance = _tmpDouble; _tmpDouble = 0; } } //距顶板距离 if (dgrdvWire.Rows[i].Cells[6].Value != null) { if (double.TryParse(dgrdvWire.Rows[i].Cells[6].Value.ToString(), out _tmpDouble)) { wirePointInfoEntity.top_distance = _tmpDouble; _tmpDouble = 0; } } //距底板距离 if (dgrdvWire.Rows[i].Cells[7].Value != null) { if (double.TryParse(dgrdvWire.Rows[i].Cells[7].Value.ToString(), out _tmpDouble)) { wirePointInfoEntity.bottom_distance = _tmpDouble; _tmpDouble = 0; } } return wirePointInfoEntity; }
public WirePoint(WirePoint wp) : this(wp.X, wp.Y, wp.IsCrossed, wp.Steps) { }