/// <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() { Direction dir = getDirection.Direction; if (dir == null) { return(null); } Observation dist = getDistance.ObservedDistance; PointFeature from = getDistance.From; if (dist == null || from == null) { return(null); } bool isdefault = intersectInfo.IsDefault; IPosition xsect, xsect1, xsect2; if (IntersectDirectionAndDistanceOperation.Calculate(dir, dist, from, isdefault, out xsect, out xsect1, out xsect2)) { return(xsect); } return(null); }
/// <summary> /// Saves a direction-distance intersection. /// </summary> /// <returns>The point feature at the intersection (null if something went wrong).</returns> PointFeature SaveDirDist() { IntersectDirectionAndDistanceOperation op = null; try { Direction dir = getDirection.Direction; IEntity e1 = getDirection.LineType; Observation dist = getDistance.ObservedDistance; PointFeature from = getDistance.From; IEntity e2 = getDistance.LineType; IdHandle pointId = intersectInfo.PointId; bool isdefault = intersectInfo.IsDefault; op = new IntersectDirectionAndDistanceOperation(dir, dist, from, 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(SaveDirDist()); } // Remember the changes as part of the UI object (the original edit remains // unchanged for now) IntersectDirectionAndDistanceOperation op = (IntersectDirectionAndDistanceOperation)up.GetOp(); UpdateItemCollection changes = op.GetUpdateItems(getDirection.Direction, getDistance.ObservedDistance, getDistance.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; }