/// <summary> /// Initializes a new instance of the <see cref="UpdatePathForm"/> class. /// </summary> /// <param name="update">The update command that's driving things (not null).</param> /// <exception cref="ArgumentNullException">If the supplied update command is null.</exception> internal UpdatePathForm(UpdateUI update) { InitializeComponent(); Owner = EditingController.Current.MainForm; if (update == null) throw new ArgumentNullException(); m_UpdCmd = update; m_CurFaceIndex = -1; m_pop = null; // Get the object that was selected for update. m_pop = (m_UpdCmd.GetOp() as PathOperation); if (m_pop == null) throw new ArgumentException("Cannot obtain original connection path for update"); // Get a working copy of the connection path legs // TODO - This will not be suitable in a situation where staggered legs have been created Leg[] legs = PathParser.CreateLegs(m_pop.EntryString, m_pop.EntryUnit); m_Faces = new List<LegFace>(); foreach (Leg leg in legs) { m_Faces.Add(leg.PrimaryFace); if (leg.AlternateFace != null) m_Faces.Add(leg.AlternateFace); } m_Edits = new PathEditor(legs); }
/// <summary> /// Create a new <c>PathInfo</c> object that corresponds to a previously /// saved connection path. For consistency with the other constructor, this /// does not attempt to adjust the path (the Rotation and ScaleFactory properties /// will retain zero values unless a call is made to Adjust). /// </summary> /// <param name="pop">The saved connection path</param> internal PathInfo(PathOperation pop) { m_From = pop.StartPoint; m_To = pop.EndPoint; m_Legs = pop.GetLegs(); m_IsAdjusted = false; m_Rotation = 0.0; m_ScaleFactor = 0.0; m_Precision = 0.0; }
/* /// <summary> /// Defines the geometry for this leg. /// </summary> /// <param name="ctx">The context in which the geometry is being calculated</param> /// <param name="terminal">The position for the start of the leg. Updated to be /// the position for the end of the leg.</param> /// <param name="bearing">The bearing at the end of the previous leg. Updated for this leg.</param> /// <param name="sfac">Scale factor to apply to distances.</param> internal override void CreateGeometry(EditingContext ctx, ref IPosition terminal, ref double bearing, double sfac) { // Add on any initial angle (it may be a deflection). bearing = AddStartAngle(bearing); // Create a straight span StraightSpan span = new StraightSpan(terminal, bearing, sfac); int nspan = this.Count; for (int i = 0; i < nspan; i++) { // Get info for the current span (this defines the // adjusted start and end positions, among other things). span.Get(this, i); // Create the geometry for the point at the end of the span SpanInfo data = GetSpanData(i); Feature feat = data.CreatedFeature; PointFeature endPoint = null; if (feat is PointFeature) endPoint = (PointFeature)feat; else if (feat is LineFeature) endPoint = (feat as LineFeature).EndPoint; if (endPoint != null && endPoint.PointGeometry == null) endPoint.ApplyPointGeometry(ctx, PointGeometry.Create(span.End)); } // Return the end position of the last span. terminal = span.End; } */ /// <summary> /// Rollforward this leg. /// </summary> /// <param name="insert">The point of the end of any new insert that /// immediately precedes this leg. This will be updated if this leg also /// ends with a new insert (if not, it will be returned as a null value).</param> /// <param name="op">The connection path that this leg belongs to.</param> /// <param name="terminal">The position for the start of the leg. Updated to be /// the position for the end of the leg.</param> /// <param name="bearing">The bearing at the end of the previous leg. /// Updated for this leg.</param> /// <param name="sfac">Scale factor to apply to distances.</param> /// <returns></returns> internal override bool Rollforward(ref PointFeature insert, PathOperation op, ref IPosition terminal, ref double bearing, double sfac) { throw new NotImplementedException(); /* // Add on any initial angle (it may be a deflection). if (Math.Abs(m_StartAngle) > MathConstants.TINY) { if (m_IsDeflection) bearing += m_StartAngle; else bearing += (m_StartAngle-Math.PI); } // Create a straight span StraightSpan span = new StraightSpan(this, terminal, bearing, sfac); // The very end of a connection path should never be moved. PointFeature veryEnd = op.EndPoint; // Create list for holding any newly created points List<PointFeature> createdPoints = new List<PointFeature>(); int nspan = this.Count; for (int i=0; i<nspan; i++) { // Get info for the current span (this defines the // adjusted start and end positions, among other things). span.Get(i); // If we've got a newly inserted span if (IsNewSpan(i)) { bool isLast = (i==(nspan-1) && op.IsLastLeg(this)); LineFeature newLine = SaveInsert(span, i, op, isLast); AddNewSpan(i, newLine); insert = newLine.EndPoint; } else { // See if the span previously had a saved feature. Feature old = GetFeature(i); if (old!=null) SaveSpan(span, op, createdPoints, insert, old, veryEnd, uc); else { Feature feat = SaveSpan(span, op, createdPoints, insert, null, veryEnd, uc); SetFeature(i, feat); } // That wasn't an insert. insert = null; } } // Return the end position of the last span. terminal = span.End; return true; */ }
/// <summary> /// Defines the geometry for this leg. /// </summary> /// <param name="ctx">The context in which the geometry is being calculated</param> /// <param name="terminal">The position for the start of the leg. Updated to be /// the position for the end of the leg.</param> /// <param name="bearing">The bearing at the end of the previous leg. Updated for this leg.</param> /// <param name="sfac">Scale factor to apply to distances.</param> //abstract internal void CreateGeometry(EditingContext ctx, ref IPosition terminal, ref double bearing, double sfac); internal abstract bool Rollforward(ref PointFeature insert, PathOperation op, ref IPosition terminal, ref double bearing, double sfac);
/// <summary> /// Rollforward this leg. /// </summary> /// <param name="insert">The point of the end of any new insert that /// immediately precedes this leg. This will be updated if this leg also /// ends with a new insert (if not, it will be returned as a null value).</param> /// <param name="op">The connection path that this leg belongs to.</param> /// <param name="terminal">The position for the start of the leg. Updated to be /// the position for the end of the leg.</param> /// <param name="bearing">The bearing at the end of the previous leg. /// Updated for this leg.</param> /// <param name="sfac">Scale factor to apply to distances.</param> /// <returns></returns> internal override bool Rollforward(ref PointFeature insert, PathOperation op, ref IPosition terminal, ref double bearing, double sfac) { throw new NotImplementedException(); /* // SS:20080314 - This looks like Save... // Create an undefined circular span CircularSpan span = new CircularSpan(this, terminal, bearing, sfac); // Create list for holding any newly created points List<PointFeature> createdPoints = new List<PointFeature>(); // If this leg already has an associated circle, move it. Otherwise // add a circle to the map that corresponds to this leg. if (m_Circle == null) m_Circle = AddCircle(op, createdPoints, span); else { // Get the centre point associated with the current op. If there // is one (i.e. it's not a point that existed before the op), just // move it. Otherwise add a new circle (along with a new centre // point). // Inactive centre points are ok (if you don't search for // them, a new circle will be added). // 19-OCT-99: During rollforward, the op returned by SaveOp is // the op where rollforward started (not necessarily the op // that this leg belongs to). This probably needs to be changed // for other reasons, but for now, use the op that was supplied // (it was not previously supplied). If you don't do this, the // GetpCentre call will not find the centre point, even if it // was created by this leg, so it would always go to add a new // circle. //const CeOperation* const pop = CeMap::GetpMap()->SaveOp(); //CePoint* pCentre = m_pCircle->GetpCentre(pop,FALSE); PointFeature center = m_Circle.CenterPoint; if (Object.ReferenceEquals(center.Creator, op)) { // Get the span to modify the radius of the circle. SetCircle(span, m_Circle); // Move the center point. center.MovePoint(uc, span.Center); } else { // The existing center point makes reference to the // circle, so clean that up. center.CutReference(m_Circle); // 19-OCT-99: The AddCircle call just returns // the circle that this leg already knows about, // so clear it first. m_Circle = null; // Add a new circle. m_Circle = AddCircle(op, createdPoints, span); } } // Create (or update) features for each span. Note that for // cul-de-sacs, there may be no observed spans. int nspan = Math.Max(1, this.Count); for (int i = 0; i < nspan; i++) { SaveSpan(ref insert, op, createdPoints, span, i, uc); } // Update BC info to refer to the EC. terminal = span.EC; bearing = span.ExitBearing; return true; */ }