/// <summary> /// Attempts to calculate the position of the intersect, using the currently /// entered information. /// </summary> /// <returns>The position of the intersect (null if there isn't one)</returns> internal override IPosition CalculateIntersect() { Observation dist1 = getDistance1.ObservedDistance; PointFeature from1 = getDistance1.From; if (from1 == null || dist1 == null) { return(null); } Observation dist2 = getDistance2.ObservedDistance; PointFeature from2 = getDistance2.From; if (from2 == null || dist2 == null) { return(null); } bool isdefault = intersectInfo.IsDefault; IPosition xsect, xsect1, xsect2; if (IntersectTwoDistancesOperation.Calculate(dist1, from1, dist2, from2, isdefault, out xsect, out xsect1, out xsect2)) { return(xsect); } return(null); }
/// <summary> /// Saves a distance-distance intersection. /// </summary> /// <returns>The point feature at the intersection (null if something went wrong).</returns> PointFeature SaveDistDist() { IntersectTwoDistancesOperation op = null; try { Observation dist1 = getDistance1.ObservedDistance; PointFeature from1 = getDistance1.From; IEntity e1 = getDistance1.LineType; Observation dist2 = getDistance2.ObservedDistance; PointFeature from2 = getDistance2.From; IEntity e2 = getDistance2.LineType; IdHandle pointId = intersectInfo.PointId; bool isdefault = intersectInfo.IsDefault; op = new IntersectTwoDistancesOperation(dist1, from1, dist2, from2, isdefault); op.Execute(pointId, e1, e2); return(op.IntersectionPoint); } catch (Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message); } return(null); }
/// <summary> /// Handles the Finish button. /// </summary> /// <returns>The point created at the intersection (null if an error was reported). /// The caller is responsible for disposing of the dialog and telling the controller /// the command is done)</returns> internal override PointFeature Finish() { // The intersection SHOULD be defined (the Finish button should have // been disabled if it wasn't) IPosition x = intersectInfo.Intersection; if (x == null) { MessageBox.Show("No intersection. Nothing to save"); return(null); } // If we're not doing an update, just save the edit UpdateUI up = (GetCommand() as UpdateUI); if (up == null) { return(SaveDistDist()); } // Remember the changes as part of the UI object (the original edit remains // unchanged for now) IntersectTwoDistancesOperation op = (IntersectTwoDistancesOperation)up.GetOp(); UpdateItemCollection changes = op.GetUpdateItems(getDistance1.ObservedDistance, getDistance1.From, getDistance2.ObservedDistance, getDistance2.From, intersectInfo.IsDefault); if (!up.AddUpdate(op, changes)) { return(null); } // Return the point previously created at the intersect return(op.IntersectionPoint); }
/// <summary> /// Initialize for an update (or recall) /// </summary> /// <param name="op">The edit that is being updated or recalled</param> /// <param name="distNum">The sequence number of the distance involved (relevant only for /// a <see cref="IntersectTwoDistancesOperation"/>)</param> internal void ShowUpdate(IntersectOperation op, int distNum) { // Return if no update object (and no recall op). if (op == null) { return; } // Populate the dialog, depending on what sort of operation we have. if (op.EditId == EditingActionId.DistIntersect) { Debug.Assert(distNum == 1 || distNum == 2); IntersectTwoDistancesOperation oper = (IntersectTwoDistancesOperation)op; if (distNum == 1) { ShowDistance(oper.Distance1FromPoint, oper.Distance1, oper.CreatedLine1); } else { ShowDistance(oper.Distance2FromPoint, oper.Distance2, oper.CreatedLine2); } } else if (op.EditId == EditingActionId.DirDistIntersect) { IntersectDirectionAndDistanceOperation oper = (IntersectDirectionAndDistanceOperation)op; ShowDistance(oper.DistanceFromPoint, oper.Distance, oper.CreatedDistanceLine); } else { MessageBox.Show("GetDistanceControl.ShowUpdate - Unexpected editing operation"); } // Disallow change of line type (you cannot add or delete lines via update). lineTypeGroupBox.Enabled = false; }