internal GetIdForm(IEntity ent, IdHandle idh) { InitializeComponent(); m_Entity = ent; m_IdHandle = idh; }
/// <summary> /// Executes this operation. /// </summary> /// <param name="pointId"></param> /// <param name="lineType"></param> internal void Execute(IdHandle pointId, IEntity lineType) { // Calculate the position of the sideshot point. IPosition to = Calculate(m_Direction, m_Length); if (to == null) { throw new Exception("Cannot calculate position of sideshot point."); } FeatureFactory ff = new FeatureFactory(this); FeatureId fid = pointId.CreateId(); IFeature x = new FeatureStub(this, pointId.Entity, fid); ff.AddFeatureDescription(DataField.To, x); if (lineType != null) { IFeature f = new FeatureStub(this, lineType, null); ff.AddFeatureDescription(DataField.Line, f); } base.Execute(ff); }
/// <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> /// Reacts to selection of the OK button in the dialog. /// </summary> /// <param name="wnd">The dialog window. If this matches the dialog that /// this command knows about, the command will be executed (and, on success, /// the dialog will be destroyed). If it's some other window, it must /// be a sub-dialog created by our guy, so let it handle the request.</param> /// <returns></returns> internal override bool DialFinish(Control wnd) { if (m_Dialog == null) { MessageBox.Show("LineExtensionUI.DialFinish - No dialog!"); return(false); } // If we are doing an update, alter the original operation. UpdateUI up = this.Update; if (up != null) { // Get the original operation. LineExtensionOperation pop = (up.GetOp() as LineExtensionOperation); if (pop == null) { MessageBox.Show("LineExtensionUI.DialFinish - Unexpected edit type."); return(false); } // Remember the changes as part of the UI object (the original edit remains // unchanged for now) UpdateItemCollection changes = pop.GetUpdateItems(m_Dialog.IsExtendFromEnd, m_Dialog.Length); if (!up.AddUpdate(pop, changes)) { return(false); } } else { // Get info from the dialog m_IsExtendFromEnd = m_Dialog.IsExtendFromEnd; m_Length = m_Dialog.Length; IdHandle idh = m_Dialog.PointId; CadastralMapModel map = CadastralMapModel.Current; m_LineType = (m_Dialog.WantLine ? map.DefaultLineType : null); // Execute the edit LineExtensionOperation op = null; try { op = new LineExtensionOperation(m_ExtendLine, m_IsExtendFromEnd, m_Length); op.Execute(idh, m_LineType); } catch (Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message); return(false); } } // Destroy the dialog(s). KillDialogs(); // Get the base class to finish up. return(FinishCommand()); }
/// <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> /// Executes this operation. /// </summary> /// <param name="pointId">The ID and entity type for the intersect point</param> /// <param name="ent1">The entity type for 1st line (null for no line)</param> /// <param name="ent2">The entity type for 2nd line (null for no line)</param> internal void Execute(IdHandle pointId, IEntity ent1, IEntity ent2) { FeatureFactory ff = new FeatureFactory(this); FeatureId fid = pointId.CreateId(); IFeature x = new FeatureStub(this, pointId.Entity, fid); ff.AddFeatureDescription(DataField.To, x); if (ent1 != null) { // Lines are not allowed if the direction line is associated with an offset // distance (since we would then need to add a point at the start of the // direction line). This should have been trapped by the UI. Note that an // offset specified using an OffsetPoint is valid. if (m_Direction.Offset is OffsetDistance) { throw new ApplicationException("Cannot add direction line because a distance offset is involved"); } IFeature f = new FeatureStub(this, ent1, null); ff.AddFeatureDescription(DataField.DirLine, f); } if (ent2 != null) { IFeature f = new FeatureStub(this, ent2, null); ff.AddFeatureDescription(DataField.DistLine, f); } base.Execute(ff); /* * // Calculate the position of the point of intersection. * IPosition xsect = Calculate(m_Direction, m_Distance, m_From, m_Default); * if (xsect==null) * throw new Exception("Cannot calculate intersection point"); * * // Add the intersection point * m_To = AddIntersection(xsect, pointId); * * // If we have a defined entity types for lines, add them too. * CadastralMapModel map = MapModel; * * if (ent1!=null) * { * IPosition start = m_Direction.StartPosition; * PointFeature ps = map.EnsurePointExists(start, this); * m_DirLine = map.AddLine(ps, m_To, ent1, this); * } * * if (ent2!=null) * m_DistLine = map.AddLine(m_From, m_To, ent2, this); * * // Peform standard completion steps * Complete(); */ }
void Zero() { m_ExtendLine = null; m_IsExtendFromEnd = true; m_Length = new Distance(); m_PointId = new IdHandle(); m_WantLine = true; }
/// <summary> /// Default constructor sets everything to null. /// </summary> public IntersectInfoControl() { InitializeComponent(); // No point feature at the intersection. m_Intersect = null; m_PointId = new IdHandle(); m_IsDefault = true; m_CloseTo = null; }
/// <summary> /// Creates basic information for a new feature that will be created by this edit. /// </summary> /// <param name="e">The entity type for the feature</param> /// <returns>Information for the new feature</returns> IFeature CreateFeatureDescription(IEntity e) { FeatureId fid = null; IdHandle h = new IdHandle(); if (h.ReserveId(e, 0)) { fid = h.CreateId(); } return(new FeatureStub(this, e, fid)); }
/// <summary> /// Creates a new <c>NewLabelUI</c> /// </summary> /// <param name="cc">The container for any dialogs</param> /// <param name="action">The action that initiated this command</param> internal NewLabelUI(IControlContainer cc, IUserAction action) : base(cc, action) { m_Schema = null; m_Template = null; m_LastRow = null; m_Polygon = null; m_PolygonId = new IdHandle(); m_IsAutoPos = Settings.Default.AutoPosition; m_IsAutoAngle = Settings.Default.AutoAngle; m_Orient = null; m_AutoPosition = null; }
/// <summary> /// Executes this operation. /// </summary> /// <param name="pointId">The key and entity type to assign to the intersection point.</param> internal void Execute(IdHandle pointId) { FeatureFactory ff = new FeatureFactory(this); FeatureId fid = pointId.CreateId(); IFeature x = new FeatureStub(this, pointId.Entity, fid); ff.AddFeatureDescription(DataField.To, x); if (m_IsSplit1) { // See FeatureFactory.MakeSection - the only thing that really matters is the // session sequence number that will get picked up by the FeatureStub constructor. ff.AddFeatureDescription(DataField.SplitBefore1, new FeatureStub(this, m_Line1.EntityType, null)); ff.AddFeatureDescription(DataField.SplitAfter1, new FeatureStub(this, m_Line1.EntityType, null)); } if (m_IsSplit2) { ff.AddFeatureDescription(DataField.SplitBefore2, new FeatureStub(this, m_Line2.EntityType, null)); ff.AddFeatureDescription(DataField.SplitAfter2, new FeatureStub(this, m_Line2.EntityType, null)); } base.Execute(ff); ////////// /* * // Calculate the position of the point of intersection. * IPosition xsect; * PointFeature closest; * if (!m_Line1.Intersect(m_Line2, m_CloseTo, out xsect, out closest)) * throw new Exception("Cannot calculate intersection point"); * * // Add the intersection point * m_Intersection = AddIntersection(xsect, pointId); * * // Are we splitting the input lines? If so, do it. * m_IsSplit1 = wantsplit1; * if (m_IsSplit1) * SplitLine(m_Intersection, m_Line1, out m_Line1a, out m_Line1b); * * m_IsSplit2 = wantsplit2; * if (m_IsSplit2) * SplitLine(m_Intersection, m_Line2, out m_Line2a, out m_Line2b); * * // Peform standard completion steps * Complete(); */ }
/// <summary> /// Executes the new label operation. /// </summary> /// <param name="vtx">The position of the new label.</param> /// <param name="polygonId">The ID and entity type to assign to the new label.</param> /// <param name="pol">The polygon that the label falls inside. It should not already refer to a label.</param> /// <param name="height">The height of the text, in meters on the ground.</param> /// <param name="width">The width of the text, in meters on the ground.</param> /// <param name="rotation">The clockwise rotation of the text, in radians from the horizontal.</param> internal void Execute(IPosition vtx, IdHandle polygonId, Polygon pol, double height, double width, double rotation) { // Add the label. CadastralMapModel map = MapModel; TextFeature text = map.AddKeyLabel(this, polygonId, vtx, height, width, rotation); SetText(text); // Associate the polygon with the label, and vice versa. text.SetTopology(true); pol.ClaimLabel(text); Complete(); }
private void NewPointForm_Load(object sender, EventArgs e) { // Display alternate window title if one has been supplied. if (!String.IsNullOrEmpty(m_Title)) { this.Text = m_Title; } ILayer layer = m_Cmd.ActiveLayer; IEntity[] entities = EnvironmentContainer.EntityTypes(SpatialType.Point, layer); Array.Sort <IEntity>(entities, delegate(IEntity a, IEntity b) { return(a.Name.CompareTo(b.Name)); }); entityTypeComboBox.DataSource = entities; // If it's not an update ... if (!InitUpdate()) { m_PointId = new IdHandle(); // Pick any default entity type (the change handler for the entity type combo will go on to load the ID combo) IEntity defEnt = CadastralMapModel.Current.DefaultPointType; if (defEnt != null) { entityTypeComboBox.SelectedItem = defEnt; // If we are auto-numbering, disable the ID combo. if (EditingController.Current.IsAutoNumber) { idComboBox.Enabled = false; } } else { idComboBox.Enabled = false; } // If the position is defined (because we're recalling // a previous command), fill in those fields too. if (Math.Abs(m_Position.X) > Double.Epsilon && Math.Abs(m_Position.Y) > Double.Epsilon) { ShowPosition(); } } }
/// <summary> /// Executes this operation. /// </summary> /// <param name="pointId">The ID and entity type for the intersect point</param> /// <param name="ent1">The entity type for 1st line (null for no line)</param> /// <param name="ent2">The entity type for 2nd line (null for no line)</param> internal void Execute(IdHandle pointId, IEntity ent1, IEntity ent2) { FeatureFactory ff = new FeatureFactory(this); FeatureId fid = pointId.CreateId(); IFeature x = new FeatureStub(this, pointId.Entity, fid); ff.AddFeatureDescription(DataField.To, x); if (ent1 != null) { IFeature f = new FeatureStub(this, ent1, null); ff.AddFeatureDescription(DataField.Line1, f); } if (ent2 != null) { IFeature f = new FeatureStub(this, ent2, null); ff.AddFeatureDescription(DataField.Line2, f); } base.Execute(ff); /* * // Calculate the position of the point of intersection. * IPosition xsect = Calculate(m_Distance1, m_From1, m_Distance2, m_From2, m_Default); * if (xsect==null) * throw new Exception("Cannot calculate intersection point"); * * // Add the intersection point * m_To = AddIntersection(xsect, pointId); * * // If we have a defined entity types for lines, add them too. * CadastralMapModel map = MapModel; * * if (ent1!=null) * m_Line1 = map.AddLine(m_From1, m_To, ent1, this); * * if (ent2!=null) * m_Line2 = map.AddLine(m_From2, m_To, ent2, this); * * // Peform standard completion steps * Complete(); */ }
/// <summary> /// Executes the new label operation. /// </summary> /// <param name="vtx">The position of the new label.</param> /// <param name="polygonId">The ID and entity type to assign to the new label.</param> /// <param name="row">The data to use for creating a row for the new label.</param> /// <param name="atemplate">The template to use in creating the RowTextGeometry /// for the new label.</param> /// <param name="pol">The polygon that the label falls inside. It should not already /// refer to a label. Not null.</param> /// <param name="height">The height of the text, in meters on the ground.</param> /// <param name="width">The width of the new label, in meters on the ground.</param> /// <param name="rotation">The clockwise rotation of the text, in radians from the horizontal.</param> internal void Execute(IPosition vtx, IdHandle polygonId, DataRow row, ITemplate atemplate, Polygon pol, double height, double width, double rotation) { if (pol == null) { throw new ArgumentNullException(); } // Add the label. TextFeature text = MapModel.AddRowLabel(this, polygonId, vtx, row, atemplate, height, width, rotation); SetText(text); // Associate the polygon with the label, and vice versa. text.SetTopology(true); pol.ClaimLabel(text); Complete(); }
/// <summary> /// Saves a direction-line intersection. /// </summary> /// <returns>The point feature at the intersection (null if something went wrong).</returns> PointFeature SaveDirLine() { IntersectDirectionAndLineOperation op = null; try { Direction dir = getDirection.Direction; IEntity dirEnt = getDirection.LineType; LineFeature line = getLine.Line; bool wantSplit = getLine.WantSplit; IdHandle pointId = intersectInfo.PointId; PointFeature closeTo = intersectInfo.ClosestPoint; if (closeTo == null) { IPosition xsect; if (!dir.Intersect(line, closeTo, out xsect, out closeTo)) { throw new Exception("Cannot calculate intersection point"); } Debug.Assert(closeTo != null); } op = new IntersectDirectionAndLineOperation(dir, line, wantSplit, closeTo); op.Execute(pointId, dirEnt); return(op.IntersectionPoint); } catch (Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message); } return(null); }
/// <summary> /// Saves a line-line intersection. /// </summary> /// <returns>The point feature at the intersection (null if something went wrong).</returns> PointFeature SaveLineLine() { IntersectTwoLinesOperation op = null; try { LineFeature line1 = getLine1.Line; bool wantSplit1 = getLine1.WantSplit; LineFeature line2 = getLine2.Line; bool wantSplit2 = getLine2.WantSplit; IdHandle pointId = intersectInfo.PointId; PointFeature closeTo = intersectInfo.ClosestPoint; if (closeTo == null) { IPosition xsect; if (!line1.Intersect(line2, null, out xsect, out closeTo)) { throw new Exception("Cannot calculate intersection point"); } Debug.Assert(closeTo != null); } op = new IntersectTwoLinesOperation(line1, wantSplit1, line2, wantSplit2, closeTo); op.Execute(pointId); return(op.IntersectionPoint); } catch (Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message); } return(null); }
/// <summary> /// Saves a direction-direction intersection. /// </summary> /// <returns>The point feature at the intersection (null if something went wrong).</returns> PointFeature SaveDirDir() { IntersectTwoDirectionsOperation op = null; try { Direction d1 = getDirection1.Direction; IEntity e1 = getDirection1.LineType; Direction d2 = getDirection2.Direction; IEntity e2 = getDirection2.LineType; IdHandle pointId = intersectInfo.PointId; op = new IntersectTwoDirectionsOperation(d1, d2); op.Execute(pointId, e1, e2); return(op.IntersectionPoint); } catch (Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message); } return(null); }
/// <summary> /// Executes this operation. /// </summary> /// <param name="pointId">The key and entity type to assign to the intersection point.</param> /// <param name="dirEnt">The entity type for any line that should be added along the direction /// line. Specify null if you don't want a line.</param> internal void Execute(IdHandle pointId, IEntity dirEnt) { FeatureFactory ff = new FeatureFactory(this); FeatureId fid = pointId.CreateId(); IFeature x = new FeatureStub(this, pointId.Entity, fid); ff.AddFeatureDescription(DataField.To, x); if (m_IsSplit) { // See FeatureFactory.MakeSection - the only thing that really matters is the // session sequence number that will get picked up by the FeatureStub constructor. ff.AddFeatureDescription(DataField.SplitBefore, new FeatureStub(this, m_Line.EntityType, null)); ff.AddFeatureDescription(DataField.SplitAfter, new FeatureStub(this, m_Line.EntityType, null)); } if (dirEnt != null) { // Lines are not allowed if the direction line is associated with an offset // distance (since we would then need to add a point at the start of the // direction line). This should have been trapped by the UI. Note that an // offset specified using an OffsetPoint is valid. if (m_Direction.Offset is OffsetDistance) throw new ApplicationException("Cannot add direction line because a distance offset is involved"); IFeature f = new FeatureStub(this, dirEnt, null); ff.AddFeatureDescription(DataField.DirLine, f); } base.Execute(ff); ////////// /* // Calculate the position of the point of intersection. IPosition xsect; PointFeature closest; if (!m_Direction.Intersect(m_Line, m_CloseTo, out xsect, out closest)) throw new Exception("Cannot calculate intersection point"); // Add the intersection point m_Intersection = AddIntersection(xsect, pointId); // Are we splitting the input line? If so, do it. m_IsSplit = wantsplit; if (m_IsSplit) SplitLine(m_Intersection, m_Line, out m_LineA, out m_LineB); // If we have a defined entity type for the direction line, add a line too. CadastralMapModel map = MapModel; if (dirEnt!=null) m_DirLine = map.AddLine(m_Direction.From, m_Intersection, dirEnt, this); // Peform standard completion steps Complete(); */ }
internal RadialControl(RadialUI cmd, PointFeature from) { InitializeComponent(); Zero(); m_Cmd = cmd; m_From = from; m_Recall = (RadialOperation)cmd.Recall; m_PointId = new IdHandle(); InitOp(m_Recall); }
private void Zero() { m_Cmd = null; m_Recall = null; m_From = null; m_Backsight = null; m_Par1 = null; m_Par2 = null; m_Radians = 0.0; m_IsClockwise = true; m_IsDeflection = false; m_Length = new Distance(); m_LengthOffset = null; m_DialOff = null; m_Offset = null; m_Dir = null; m_To = null; m_Circles = new List<Circle>(); m_Focus = null; m_WantLine = false; m_WantCentre = false; m_IsStatic = false; m_PointId = null; }
/// <summary> /// Reacts to selection of the OK button in the dialog. /// </summary> /// <param name="wnd">The dialog window. If this matches the dialog that /// this command knows about, the command will be executed (and, on success, /// the dialog will be destroyed). If it's some other window, it must /// be a sub-dialog created by our guy, so let it handle the request.</param> /// <returns></returns> internal override bool DialFinish(Control wnd) { if (m_Dialog == null) { MessageBox.Show("RadialUI.DialFinish - No dialog!"); return(false); } // Handle any sub-dialog request. if (m_Dialog != wnd) { return(m_Dialog.DialFinish(wnd)); } // If we are doing an update, remember the changes UpdateUI up = this.Update; if (up != null) { RadialOperation pop = (up.GetOp() as RadialOperation); if (pop == null) { MessageBox.Show("RadialUI.DialFinish - Unexpected edit type."); return(false); } // Get info from the dialog. Direction dir = m_Dialog.Direction; Observation len = m_Dialog.Length; // The direction and length must both be defined. if (dir == null || len == null) { MessageBox.Show("Missing parameters for sideshot update."); return(false); } // Remember the changes as part of the UI object (the original edit remains // unchanged for now) UpdateItemCollection changes = pop.GetUpdateItems(dir, len); if (!up.AddUpdate(pop, changes)) { return(false); } } else { // Get info from the dialog. Direction dir = m_Dialog.Direction; Observation len = m_Dialog.Length; IdHandle idh = m_Dialog.PointId; IEntity lineEnt = null; if (m_Dialog.WantLine) { lineEnt = CadastralMapModel.Current.DefaultLineType; if (lineEnt == null) { throw new InvalidOperationException("No default entity type for lines"); } } // The direction, length, and point entity type must all be defined. if (dir == null || len == null || idh.Entity == null) { MessageBox.Show("Missing parameters for sideshot creation."); return(false); } RadialOperation pop = null; try { pop = new RadialOperation(dir, len); pop.Execute(idh, lineEnt); } catch (Exception ex) { MessageBox.Show(ex.StackTrace, ex.Message); } } // Get the base class to finish up. return(FinishCommand()); }
/// <summary> /// Executes the new label operation. /// </summary> /// <param name="vtx">The position of the new label.</param> /// <param name="polygonId">The ID and entity type to assign to the new label.</param> /// <param name="row">The data to use for creating a row for the new label.</param> /// <param name="atemplate">The template to use in creating the RowTextGeometry /// for the new label.</param> /// <param name="pol">The polygon that the label falls inside. It should not already /// refer to a label. Not null.</param> /// <param name="height">The height of the text, in meters on the ground.</param> /// <param name="width">The width of the new label, in meters on the ground.</param> /// <param name="rotation">The clockwise rotation of the text, in radians from the horizontal.</param> internal void Execute(IPosition vtx, IdHandle polygonId, DataRow row, ITemplate atemplate, Polygon pol, double height, double width, double rotation) { if (pol == null) throw new ArgumentNullException(); // Add the label. TextFeature text = MapModel.AddRowLabel(this, polygonId, vtx, row, atemplate, height, width, rotation); SetText(text); // Associate the polygon with the label, and vice versa. text.SetTopology(true); pol.ClaimLabel(text); Complete(); }
/// <summary> /// Executes this operation. /// </summary> /// <param name="pointId">The ID (and entity type) for the extension point.</param> /// <param name="lineEnt">The entity type for the extension line (null for no line).</param> internal void Execute(IdHandle pointId, IEntity lineEnt) { FeatureFactory ff = new FeatureFactory(this); FeatureId fid = pointId.CreateId(); IFeature xp = new FeatureStub(this, pointId.Entity, fid); ff.AddFeatureDescription(DataField.NewPoint, xp); if (lineEnt != null) { IFeature f = new FeatureStub(this, lineEnt, null); ff.AddFeatureDescription(DataField.NewLine, f); } base.Execute(ff); /* IPosition start; // Start of the extension IPosition end; // End of the extension // See if the extension is a straight line. bool isStraight = LineExtensionUI.Calculate(m_ExtendLine, m_IsExtendFromEnd, m_Length, out start, out end); // If it's not straight, it should be a circular arc. bool isCurve = false; IPosition center; // The centre of the circle bool iscw = true; // Is the curve clockwise? if (!isStraight) isCurve = LineExtensionUI.Calculate(m_ExtendLine, m_IsExtendFromEnd, m_Length, out start, out end, out center, out iscw); // Return if it's neither straight or a circular arc. if ( !(isStraight || isCurve) ) throw new Exception("Cannot calculate line extension point."); // Add the extension point to the map. CadastralMapModel map = MapModel; m_NewPoint = map.AddPoint(end, pointId.Entity, this); // Associate the new point with the specified ID (if any). pointId.CreateId(m_NewPoint); // If a line entity has been supplied, add a line too. if (lineEnt==null) m_NewLine = null; else { // Get the point at the end of the extension line PointFeature s = (m_IsExtendFromEnd ? m_ExtendLine.EndPoint : m_ExtendLine.StartPoint); if (isStraight) m_NewLine = map.AddLine(s, m_NewPoint, lineEnt, this); else { // We need the circle that the arc lies on. Circle circle = m_ExtendLine.Circle; Debug.Assert(circle!=null); // Add the arc to the map. m_NewLine = map.AddCircularArc(circle, s, m_NewPoint, iscw, lineEnt, this); } } // Peform standard completion steps Complete(); */ }
/// <summary> /// Executes this operation. /// </summary> /// <param name="pointId"></param> /// <param name="lineType"></param> internal void Execute(IdHandle pointId, IEntity lineType) { // Calculate the position of the sideshot point. IPosition to = Calculate(m_Direction, m_Length); if (to==null) throw new Exception("Cannot calculate position of sideshot point."); FeatureFactory ff = new FeatureFactory(this); FeatureId fid = pointId.CreateId(); IFeature x = new FeatureStub(this, pointId.Entity, fid); ff.AddFeatureDescription(DataField.To, x); if (lineType != null) { IFeature f = new FeatureStub(this, lineType, null); ff.AddFeatureDescription(DataField.Line, f); } base.Execute(ff); }
/// <summary> /// Executes this operation. /// </summary> /// <param name="pointId">The ID (and entity type) for the extension point.</param> /// <param name="lineEnt">The entity type for the extension line (null for no line).</param> internal void Execute(IdHandle pointId, IEntity lineEnt) { FeatureFactory ff = new FeatureFactory(this); FeatureId fid = pointId.CreateId(); IFeature xp = new FeatureStub(this, pointId.Entity, fid); ff.AddFeatureDescription(DataField.NewPoint, xp); if (lineEnt != null) { IFeature f = new FeatureStub(this, lineEnt, null); ff.AddFeatureDescription(DataField.NewLine, f); } base.Execute(ff); /* * IPosition start; // Start of the extension * IPosition end; // End of the extension * * // See if the extension is a straight line. * bool isStraight = LineExtensionUI.Calculate(m_ExtendLine, m_IsExtendFromEnd, m_Length, out start, out end); * * // If it's not straight, it should be a circular arc. * bool isCurve = false; * IPosition center; // The centre of the circle * bool iscw = true; // Is the curve clockwise? * * if (!isStraight) * isCurve = LineExtensionUI.Calculate(m_ExtendLine, m_IsExtendFromEnd, m_Length, out start, out end, out center, out iscw); * * // Return if it's neither straight or a circular arc. * if ( !(isStraight || isCurve) ) * throw new Exception("Cannot calculate line extension point."); * * // Add the extension point to the map. * CadastralMapModel map = MapModel; * m_NewPoint = map.AddPoint(end, pointId.Entity, this); * * // Associate the new point with the specified ID (if any). * pointId.CreateId(m_NewPoint); * * // If a line entity has been supplied, add a line too. * if (lineEnt==null) * m_NewLine = null; * else * { * // Get the point at the end of the extension line * PointFeature s = (m_IsExtendFromEnd ? m_ExtendLine.EndPoint : m_ExtendLine.StartPoint); * * if (isStraight) * m_NewLine = map.AddLine(s, m_NewPoint, lineEnt, this); * else * { * // We need the circle that the arc lies on. * Circle circle = m_ExtendLine.Circle; * Debug.Assert(circle!=null); * * // Add the arc to the map. * m_NewLine = map.AddCircularArc(circle, s, m_NewPoint, iscw, lineEnt, this); * } * } * * // Peform standard completion steps * Complete(); */ }
/// <summary> /// Executes this operation. /// </summary> /// <param name="pointId">The key and entity type to assign to the intersection point.</param> /// <param name="dirEnt">The entity type for any line that should be added along the direction /// line. Specify null if you don't want a line.</param> internal void Execute(IdHandle pointId, IEntity dirEnt) { FeatureFactory ff = new FeatureFactory(this); FeatureId fid = pointId.CreateId(); IFeature x = new FeatureStub(this, pointId.Entity, fid); ff.AddFeatureDescription(DataField.To, x); if (m_IsSplit) { // See FeatureFactory.MakeSection - the only thing that really matters is the // session sequence number that will get picked up by the FeatureStub constructor. ff.AddFeatureDescription(DataField.SplitBefore, new FeatureStub(this, m_Line.EntityType, null)); ff.AddFeatureDescription(DataField.SplitAfter, new FeatureStub(this, m_Line.EntityType, null)); } if (dirEnt != null) { // Lines are not allowed if the direction line is associated with an offset // distance (since we would then need to add a point at the start of the // direction line). This should have been trapped by the UI. Note that an // offset specified using an OffsetPoint is valid. if (m_Direction.Offset is OffsetDistance) { throw new ApplicationException("Cannot add direction line because a distance offset is involved"); } IFeature f = new FeatureStub(this, dirEnt, null); ff.AddFeatureDescription(DataField.DirLine, f); } base.Execute(ff); ////////// /* * // Calculate the position of the point of intersection. * IPosition xsect; * PointFeature closest; * if (!m_Direction.Intersect(m_Line, m_CloseTo, out xsect, out closest)) * throw new Exception("Cannot calculate intersection point"); * * // Add the intersection point * m_Intersection = AddIntersection(xsect, pointId); * * // Are we splitting the input line? If so, do it. * m_IsSplit = wantsplit; * if (m_IsSplit) * SplitLine(m_Intersection, m_Line, out m_LineA, out m_LineB); * * // If we have a defined entity type for the direction line, add a line too. * CadastralMapModel map = MapModel; * if (dirEnt!=null) * m_DirLine = map.AddLine(m_Direction.From, m_Intersection, dirEnt, this); * * // Peform standard completion steps * Complete(); */ }
/// <summary> /// Executes this operation. /// </summary> /// <param name="pointId">The ID and entity type for the intersect point</param> /// <param name="ent1">The entity type for 1st line (null for no line)</param> /// <param name="ent2">The entity type for 2nd line (null for no line)</param> internal void Execute(IdHandle pointId, IEntity ent1, IEntity ent2) { FeatureFactory ff = new FeatureFactory(this); FeatureId fid = pointId.CreateId(); IFeature x = new FeatureStub(this, pointId.Entity, fid); ff.AddFeatureDescription(DataField.To, x); if (ent1 != null) { IFeature f = new FeatureStub(this, ent1, null); ff.AddFeatureDescription(DataField.Line1, f); } if (ent2 != null) { IFeature f = new FeatureStub(this, ent2, null); ff.AddFeatureDescription(DataField.Line2, f); } base.Execute(ff); /* // Calculate the position of the point of intersection. IPosition xsect = Calculate(m_Distance1, m_From1, m_Distance2, m_From2, m_Default); if (xsect==null) throw new Exception("Cannot calculate intersection point"); // Add the intersection point m_To = AddIntersection(xsect, pointId); // If we have a defined entity types for lines, add them too. CadastralMapModel map = MapModel; if (ent1!=null) m_Line1 = map.AddLine(m_From1, m_To, ent1, this); if (ent2!=null) m_Line2 = map.AddLine(m_From2, m_To, ent2, this); // Peform standard completion steps Complete(); */ }
private void NewPointForm_Load(object sender, EventArgs e) { // Display alternate window title if one has been supplied. if (!String.IsNullOrEmpty(m_Title)) this.Text = m_Title; ILayer layer = m_Cmd.ActiveLayer; IEntity[] entities = EnvironmentContainer.EntityTypes(SpatialType.Point, layer); Array.Sort<IEntity>(entities, delegate(IEntity a, IEntity b) { return a.Name.CompareTo(b.Name); }); entityTypeComboBox.DataSource = entities; // If it's not an update ... if (!InitUpdate()) { m_PointId = new IdHandle(); // Pick any default entity type (the change handler for the entity type combo will go on to load the ID combo) IEntity defEnt = CadastralMapModel.Current.DefaultPointType; if (defEnt!=null) { entityTypeComboBox.SelectedItem = defEnt; // If we are auto-numbering, disable the ID combo. if (EditingController.Current.IsAutoNumber) idComboBox.Enabled = false; } else idComboBox.Enabled = false; // If the position is defined (because we're recalling // a previous command), fill in those fields too. if (Math.Abs(m_Position.X)>Double.Epsilon && Math.Abs(m_Position.Y)>Double.Epsilon) ShowPosition(); } }
/// <summary> /// Executes this operation. /// </summary> /// <param name="pointId">The ID and entity type for the intersect point /// If null, the default entity type for point features will be used.</param> /// <param name="lineEnt1">The entity type for a line connecting the 1st direction to the /// intersection (null for no line)</param> /// <param name="lineEnt2">The entity type for a line connecting the 2nd direction to the /// intersection (null for no line)</param> internal void Execute(IdHandle pointId, IEntity lineEnt1, IEntity lineEnt2) { FeatureFactory ff = new FeatureFactory(this); FeatureId fid = pointId.CreateId(); IFeature x = new FeatureStub(this, pointId.Entity, fid); ff.AddFeatureDescription(DataField.To, x); if (lineEnt1 != null) { // Lines are not allowed if the direction line is associated with an offset // distance (since we would then need to add a point at the start of the // direction line). This should have been trapped by the UI. Note that an // offset specified using an OffsetPoint is valid. if (m_Direction1.Offset is OffsetDistance) throw new ApplicationException("Cannot add direction line because a distance offset is involved"); IFeature f = new FeatureStub(this, lineEnt1, null); ff.AddFeatureDescription(DataField.Line1, f); } if (lineEnt2 != null) { if (m_Direction2.Offset is OffsetDistance) throw new ApplicationException("Cannot add direction line because a distance offset is involved"); IFeature f = new FeatureStub(this, lineEnt2, null); ff.AddFeatureDescription(DataField.Line2, f); } base.Execute(ff); /* // Calculate the position of the point of intersection. IPosition xsect = m_Direction1.Intersect(m_Direction2); if (xsect==null) throw new Exception("Cannot calculate intersection point"); // Add the intersection point m_To = AddIntersection(xsect, pointId); // If we have a defined entity types for lines, add them too. CadastralMapModel map = MapModel; if (lineEnt1!=null) { IPosition start = m_Direction1.StartPosition; PointFeature ps = map.EnsurePointExists(start, this); m_Line1 = map.AddLine(ps, m_To, lineEnt1, this); } if (lineEnt2!=null) { IPosition start = m_Direction2.StartPosition; PointFeature ps = map.EnsurePointExists(start, this); m_Line2 = map.AddLine(ps, m_To, lineEnt2, this); } // Peform standard completion steps Complete(); */ }
/// <summary> /// Executes this operation. /// </summary> /// <param name="pointId">The key and entity type to assign to the intersection point.</param> internal void Execute(IdHandle pointId) { FeatureFactory ff = new FeatureFactory(this); FeatureId fid = pointId.CreateId(); IFeature x = new FeatureStub(this, pointId.Entity, fid); ff.AddFeatureDescription(DataField.To, x); if (m_IsSplit1) { // See FeatureFactory.MakeSection - the only thing that really matters is the // session sequence number that will get picked up by the FeatureStub constructor. ff.AddFeatureDescription(DataField.SplitBefore1, new FeatureStub(this, m_Line1.EntityType, null)); ff.AddFeatureDescription(DataField.SplitAfter1, new FeatureStub(this, m_Line1.EntityType, null)); } if (m_IsSplit2) { ff.AddFeatureDescription(DataField.SplitBefore2, new FeatureStub(this, m_Line2.EntityType, null)); ff.AddFeatureDescription(DataField.SplitAfter2, new FeatureStub(this, m_Line2.EntityType, null)); } base.Execute(ff); ////////// /* // Calculate the position of the point of intersection. IPosition xsect; PointFeature closest; if (!m_Line1.Intersect(m_Line2, m_CloseTo, out xsect, out closest)) throw new Exception("Cannot calculate intersection point"); // Add the intersection point m_Intersection = AddIntersection(xsect, pointId); // Are we splitting the input lines? If so, do it. m_IsSplit1 = wantsplit1; if (m_IsSplit1) SplitLine(m_Intersection, m_Line1, out m_Line1a, out m_Line1b); m_IsSplit2 = wantsplit2; if (m_IsSplit2) SplitLine(m_Intersection, m_Line2, out m_Line2a, out m_Line2b); // Peform standard completion steps Complete(); */ }