private void ArcForm_Shown(object sender, EventArgs e) { // Entry and exit angles bcAngleTextBox.Text = RadianValue.AsShortString(m_Angle1); ecAngleTextBox.Text = RadianValue.AsShortString(m_Angle2); // If the curve is already defined (e.g. we are doing an update), // display the prviously defined stuff. Otherwise just initialize // for a clockwise curve (see default constructor). if (m_IsDefined) { // Observed radius radiusTextBox.Text = m_Radius.Format(); // Direction of curve if (m_IsClockwise) { OnClockwise(); } else { OnCounterClockwise(); } } else { OnClockwise(); } // Always start in the radius field. radiusTextBox.Focus(); }
/// <summary> /// Initializes a new instance of the <see cref="AngleDirection"/> class /// using the data read from persistent storage. /// </summary> /// <param name="editDeserializer">The mechanism for reading back content.</param> internal AngleDirection(EditDeserializer editDeserializer) : base(editDeserializer) { m_Backsight = editDeserializer.ReadFeatureRef<PointFeature>(this, DataField.Backsight); m_From = editDeserializer.ReadFeatureRef<PointFeature>(this, DataField.From); m_Observation = editDeserializer.ReadRadians(DataField.Value); }
internal string Format() { // Return empty string if angle is undefined. Otherwise return // angle in DMS, with leading "-" if it's counter-clockwise. if (!m_IsDefined) { return(String.Empty); } string result; if (m_IsClockwise) { result = RadianValue.AsShortString(m_Radians); } else { result = RadianValue.AsShortString(-m_Radians); } if (m_IsDeflection) { result += "d"; } // Append a space result += " "; return(result); }
/// <summary> /// Initializes a new instance of the <see cref="AngleDirection"/> class /// using the data read from persistent storage. /// </summary> /// <param name="editDeserializer">The mechanism for reading back content.</param> internal AngleDirection(EditDeserializer editDeserializer) : base(editDeserializer) { m_Backsight = editDeserializer.ReadFeatureRef <PointFeature>(this, DataField.Backsight); m_From = editDeserializer.ReadFeatureRef <PointFeature>(this, DataField.From); m_Observation = editDeserializer.ReadRadians(DataField.Value); }
internal override void ShowResult() { base.ShowResult(); // Now show the bearings too. Don't bother if we've // only got 1 point, since that may involve more than // one circle (also true when we have 2 points, but in // that case, we use the first circle arbitrarily). if (Point1 != null && Point2 != null) { // It's conceivable that the two points share more than // one common circle. For now, just pick off the first // common circle and use that. Circle circle = FirstCommonCircle; if (circle == null) { return; } // Get the bearing from the center to both points double bear1 = Geom.BearingInRadians(Point1, circle.Center); double bear2 = Geom.BearingInRadians(Point2, circle.Center); bearing1TextBox.Text = RadianValue.AsString(bear1); bearing2TextBox.Text = RadianValue.AsString(bear2); } else { bearing1TextBox.Text = bearing2TextBox.Text = "<no bearing>"; } }
/// <summary> /// Initializes a new instance of the <see cref="TextRotationOperation"/> class /// using the data read from persistent storage. /// </summary> /// <param name="editDeserializer">The mechanism for reading back content.</param> internal TextRotationOperation(EditDeserializer editDeserializer) : base(editDeserializer) { RadianValue value = editDeserializer.ReadRadians(DataField.Value); m_Rotation = value.Radians; }
void ShowResult() { // If we have the first two points, get the distance between // them, format the result, and display it. if (m_Point1 != null && m_Point2 != null) { double metric = Geom.Distance(m_Point1, m_Point2); distance1TextBox.Text = Format(metric, m_Point1, m_Point2); } // Same for the second pair of points. if (m_Point2 != null && m_Point3 != null) { double metric = Geom.Distance(m_Point2, m_Point3); distance2TextBox.Text = Format(metric, m_Point2, m_Point3); } // If we have all 3 points, display the angle. if (m_Point1 != null && m_Point2 != null && m_Point3 != null) { // Get the clockwise angle. Turn reft = new Turn(m_Point2, m_Point1); double ang = reft.GetAngleInRadians(m_Point3); // Get the complement if we actually want it anti-clockwise. if (!m_Clockwise) { ang = Constants.PIMUL2 - ang; } angleTextBox.Text = RadianValue.AsString(ang); } }
private void CulDeSacForm_Shown(object sender, EventArgs e) { // If the curve is already defined (e.g. we are doing an update), // display the previously defined stuff. Otherwise just initialize // for a clockwise curve (see default constructor). if (m_IsDefined) { // Central angle angleTextBox.Text = RadianValue.AsShortString(m_Radians); // Observed radius radiusTextBox.Text = m_Radius.Format(); // Direction of curve if (m_IsClockwise) { OnClockwise(); } else { OnCounterClockwise(); } } else { OnClockwise(); } }
/// <summary> /// Constructor /// </summary> /// <param name="from">The point which the bearing was taken from.</param> /// <param name="observation">The observed bearing. If this is outwith the range /// [0,2PI), the value stored will be fixed so that it is in the expected range. /// </param> internal BearingDirection(PointFeature from, IAngle observation) { double a = observation.Radians; m_Observation = new RadianValue(Direction.Normalize(a)); m_From = from; }
void ShowLabelsPage(CadastralMapModel cmm) { ProjectSettings ps = EditingController.Current.Project.Settings; labelScaleTextBox.Text = String.Format("{0:F0}", ps.ShowLabelScale); textRotationAngleLabel.Text = RadianValue.AsShortString(cmm.DefaultTextRotation); nominalScaleTextBox.Text = ps.NominalMapScale.ToString(); ShowFont(); }
internal override void ShowResult() { base.ShowResult(); // Now show the bearing too. if (Point1 != null && Point2 != null) { double bearing = Geom.BearingInRadians(Point1, Point2); bearingTextBox.Text = RadianValue.AsString(bearing); } }
/// <summary> /// Parses an explicitly entered angle. /// </summary> /// <param name="tb">The control containing the entered angle</param> /// <returns>True if angle parses ok.</returns> bool ParseAngle(TextBox tb) { // Get the entered string. string str = tb.Text.Trim(); // A leading "-" is not expected. if (str.Length > 0 && str[0] == '-') { MessageBox.Show("Angles should not be signed."); return(false); } // Validate entered angle. When dealing with the exit angle, only treat // it as an error if the field contains something. This assumes that // the entry angle is parsed FIRST. if (str.Length == 0) { if (!Object.ReferenceEquals(tb, ecAngleTextBox)) { MessageBox.Show("The angle at the BC must be specified."); return(false); } m_Angle2 = m_Angle1; return(true); } double srad; if (!RadianValue.TryParse(str, out srad)) { MessageBox.Show("Invalid angle."); return(false); } if (Object.ReferenceEquals(tb, bcAngleTextBox)) { m_Angle1 = Math.Abs(srad); } else { m_Angle2 = Math.Abs(srad); } return(true); }
private void AngleForm_Shown(object sender, EventArgs e) { // Return if the angle isn't defined. if (!m_IsDefined) { return; } if (m_IsClockwise) { clockwiseRadioButton.Checked = true; counterClockwiseRadioButton.Checked = false; } else { clockwiseRadioButton.Checked = false; counterClockwiseRadioButton.Checked = true; } deflectionCheckBox.Checked = m_IsDeflection; angleTextBox.Text = RadianValue.AsShortString(m_Radians); }
internal string Format() { // Return empty string if angle is undefined. Otherwise return // 1 or 2 angles in DMS, followed by radius and any // counter-clockwise curve indicator. if (!m_IsDefined) { return(String.Empty); } string result; if (Math.Abs(m_Angle1 - m_Angle2) < MathConstants.TINY) { result = String.Format("({0} {1}", RadianValue.AsShortString(m_Angle1), m_Radius.Format()); } else { result = String.Format("({0} {1} {2}", RadianValue.AsShortString(m_Angle1), RadianValue.AsShortString(m_Angle2), m_Radius.Format()); } if (m_IsClockwise) { result += "/ "; } else { result += " CC/ "; } return(result); }
/// <summary> /// Parses an explicitly entered angle. /// </summary> /// <returns>True if angle parses ok.</returns> bool ParseAngle() { // Get the entered string. string str = angleTextBox.Text.Trim(); // A leading "-" is not expected. if (str.Length > 0 && str[0] == '-') { MessageBox.Show("Central angles are not signed."); return(false); } // Validate entered angle. double srad; if (!RadianValue.TryParse(str, out srad)) { MessageBox.Show("Invalid central angle."); return(false); } m_Radians = Math.Abs(srad); return(true); }
internal string Format() { // Return empty string if angle is undefined. Otherwise return // angle in DMS, followed by radius. if (!m_IsDefined) { return(String.Empty); } string result = String.Format("({0}ca {1}", RadianValue.AsShortString(m_Radians), m_Radius.Format()); if (m_IsClockwise) { result += "/ "; } else { result += " cc/ "; } return(result); }
internal void SetObservationInRadians(double value) { m_Observation = new RadianValue(value); }
/// <summary> /// Initializes a new instance of the <see cref="AngleDirection"/> class. /// </summary> /// <param name="backsight">The backsight point.</param> /// <param name="occupied">The occupied station.</param> /// <param name="observation">The angle to an observed point, measured with respect /// to the reference orientation defined by the backsight. Positive values indicate /// a clockwise rotation & negated values for counter-clockwise.</param> internal AngleDirection(PointFeature backsight, PointFeature occupied, IAngle observation) { m_Backsight = backsight; m_From = occupied; m_Observation = new RadianValue(observation.Radians); }
/// <summary> /// Checks whether the current data is enough to construct a direction. If so, /// draw it. Take care to erase any previously drawn direction. /// </summary> void OnChange() { Direction dir=null; // Constructed direction. AngleDirection angle; // Angle from a backsight. DeflectionDirection deflect; // Deflection angle. BearingDirection bearing; // Bearing from north. ParallelDirection par; // Parallel to 2 points. double srad; // Signed radian value. // Apply sign to any angle we have. if (m_IsClockwise) srad = m_Radians; else srad = -m_Radians; if (m_Backsight!=null) { // If we have a backsight, we could either have a regular // angle or a deflection. To construct either, we need a // from-point as well. // Note that an angle of zero (passing through the backsight // or foresight) is fine. if (m_From!=null) { IAngle obsv = new RadianValue(srad); if (m_IsDeflection) { deflect = new DeflectionDirection(m_Backsight, m_From, obsv); dir = deflect; } else { angle = new AngleDirection(m_Backsight, m_From, obsv); dir = angle; } } } else if (m_From!=null) { // No backsight, so we could have either a bearing, // or a direction defined using 2 parallel points. // Since a bearing of zero is quite valid, we check // the dialog field to see if this is an entered value, // or just the initial value. if (m_Par1!=null && m_Par2!=null) { par = new ParallelDirection(m_From, m_Par1, m_Par2); dir = par; } else { if (m_Radians>Constants.TINY || angleTextBox.Text.Trim().Length==0) { bearing = new BearingDirection(m_From, new RadianValue(srad)); dir = bearing; } } } // If we have formed a direction, apply any offset. if (dir!=null) dir.Offset = m_Offset; // Try to calulate the position of the sideshot. IPosition to = RadialOperation.Calculate(dir, this.Length); // Return if we calculated a position that is identical to the old one. //if (to!=null && to.IsAt(m_To, Double.Epsilon)) // return; m_Dir = dir; m_To = to; m_Cmd.ErasePainting(); }
/// <summary> /// Uses the currently displayed information to try to construct a /// direction object. /// </summary> /// <returns>The constructed direction (null if a direction cannot be created /// based on the information that's currently displayed)</returns> Direction GetCurrentDirection() { Direction result = null; // Get signed direction double srad = (m_IsClockwise ? m_Radians : -m_Radians); IAngle dir = new RadianValue(srad); if (m_Backsight!=null) { // If we have a backsight, we could either have a regular // angle or a deflection. To construct either, we need a // from-point as well. // Note that an angle of zero (passing through the backsight // or foresight) is fine. if (m_From!=null) { if (m_IsDeflection) result = new DeflectionDirection(m_Backsight, m_From, dir); else result = new AngleDirection(m_Backsight, m_From, dir); } } else if (m_From!=null) { // No backsight, so we could have either a bearing, // or a direction defined using 2 parallel points. // Since a bearing of zero is quite valid, we check // the dialog field to see if this is an entered value, // or just the initial value. if (m_Par1!=null && m_Par2!=null) result = new ParallelDirection(m_From, m_Par1, m_Par2); else if (m_Radians > Constants.TINY || directionTextBox.Text.Length>0) result = new BearingDirection(m_From, dir); } // If we haven't formed a direction, ignore any offset if (result==null) return null; // An offset could have been specified by a point, or by // entering a distance left or right of the direction. Offset offset = null; if (m_OffsetPoint!=null) offset = new OffsetPoint(m_OffsetPoint); else if (m_OffsetDistance!=null) offset = new OffsetDistance(m_OffsetDistance, !m_IsRight); // If we got an offset, include it in the direction. if (offset!=null) result.Offset = offset; return result; }
/// <summary> /// Parses an explicitly entered angle. /// </summary> /// <returns>True if angle parses ok.</returns> bool ParseAngle() { // Get the entered string. string dirstr = angleTextBox.Text.Trim(); // If all we have is a "-", disable the ability to specify // clockwise angle & return. if (dirstr.Length > 0 && dirstr[0] == '-') { clockwiseRadioButton.Enabled = false; clockwiseRadioButton.Checked = false; counterClockwiseRadioButton.Checked = true; if (dirstr.Length == 1) { return(false); } } // If the entered angle contains a "d" (anywhere), treat it // as a deflection (and strip it out). dirstr = dirstr.ToUpper(); if (dirstr.Contains("D")) { dirstr = dirstr.Replace("D", String.Empty); m_IsDeflection = true; deflectionCheckBox.Checked = true; } // Validate entered angle. double srad = 0.0; if (dirstr.Length > 0) { double trad; if (!RadianValue.TryParse(dirstr, out trad)) { MessageBox.Show("Invalid angle."); angleTextBox.Focus(); return(false); } srad = trad; } // If we have signed radians, it HAS to be a counter-clockwise // angle. Otherwise make sure we preserve the directional sense. // which may have been previously defined. if (srad < 0.0) { m_IsClockwise = false; } m_Radians = Math.Abs(srad); // Ensure radio buttons are in sync with what we have. if (m_IsClockwise) { OnClockwise(); } else { OnCounterClockwise(); } return(true); }