/// <summary>
        /// Initializes a new instance of the <see cref="IntersectDirectionAndDistanceOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal IntersectDirectionAndDistanceOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            m_Direction = editDeserializer.ReadPersistent<Direction>(DataField.Direction);
            m_Distance = editDeserializer.ReadPersistent<Observation>(DataField.Distance);
            m_From = editDeserializer.ReadFeatureRef<PointFeature>(this, DataField.From);
            m_Default = editDeserializer.ReadBool(DataField.Default);
            FeatureStub to = editDeserializer.ReadPersistent<FeatureStub>(DataField.To);
            FeatureStub dirLine = editDeserializer.ReadPersistentOrNull<FeatureStub>(DataField.DirLine);
            FeatureStub distLine = editDeserializer.ReadPersistentOrNull<FeatureStub>(DataField.DistLine);

            DeserializationFactory dff = new DeserializationFactory(this);
            dff.AddFeatureStub(DataField.To, to);
            dff.AddFeatureStub(DataField.DirLine, dirLine);
            dff.AddFeatureStub(DataField.DistLine, distLine);
            ProcessFeatures(dff);
        }
        /// <summary>
        /// Checks whether the current data is enough to construct a direction.
        /// If so, draw it.
        /// </summary>
        void OnNewDirection()
        {
            setDefaultOffsetButton.Enabled = CanSetDefaultOffset();

            // Try to construct direction based on what's been entered
            Direction dir = GetCurrentDirection();

            if (dir==null)
            {
                // If we didn't get anything, but we previously had a direction, ensure
                // it gets erased.
                if (m_Dir!=null)
                {
                    m_Dir = null;
                    ErasePainting();
                }
            }
            else
            {
                // Just return if current direction matches what we've already got
                if (m_Dir!=null && m_Dir.IsEquivalent(dir))
                    return;

                // Draw the new direction
                m_Dir = dir;
                ErasePainting();
            }
        }
        /// <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>
        /// Displays any offset info for a direction.
        /// </summary>
        /// <param name="dir">The direction that may have an offset.</param>
        void ShowOffset(Direction dir)
        {
            // Initialize offset-related data members.
            m_IsRight = true;
            m_OffsetDistance = null;
            m_OffsetPoint = null;

            // Return if there is no offset.
            Offset offset = dir.Offset;
            if (offset==null)
                return;

            // It could be one of 2 types of offset.
            if (offset is OffsetDistance)
            {
                OffsetDistance dist = (offset as OffsetDistance);

                // Display the offset distance, in the current data entry units.
                // Setting the window text will end up calling OnChangeOffset,
                // which calls OnOffsetDistance, where it will be deduced that
                // we have an offset to the right. This may or may not be correct.

                m_OffsetDistance = dist.Offset;
                DistanceUnit entry = EditingController.Current.EntryUnit;
                offsetTextBox.Text = m_OffsetDistance.Format(entry, true);

                // Override whatever we got above.
                m_IsRight = dist.IsRight;

                if (m_IsRight)
                    SetOffsetRight();
                else
                    SetOffsetLeft();
            }
            else
            {
                // It SHOULD be an offset point.
                OffsetPoint point = (offset as OffsetPoint);
                if (point!=null)
                {
                    // Display the ID of the offset point.
                    m_OffsetPoint = point.Point;
                    ShowKey(offsetTextBox, m_OffsetPoint);

                    // Disable (and turn off) the radio buttons to allow right or left specification.
                    TurnRadioOff(leftRadioButton);
                    TurnRadioOff(rightRadioButton);
                }
                else
                    MessageBox.Show("GetDirectionControl.ShowOffset - Unexpected type of offset.");
            }
        }
        /// <summary>
        /// Default constructor
        /// </summary>
        public GetDirectionControl()
        {
            InitializeComponent();

            m_DefaultOffset = null;
            m_Backsight = null;
            m_From = null;
            m_Par1 = null;
            m_Par2 = null;
            m_Radians = 0.0;
            m_IsDeflection = false;
            m_IsClockwise = true;
            m_OffsetDistance = null;
            m_IsRight = true;
            m_OffsetPoint = null;
            m_LineType = null;
            m_Dir = null;
            m_Circles = new List<Circle>();
            m_WantCentre = false;
            m_Focus = null;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="IntersectTwoDirectionsOperation"/> class.
 /// </summary>
 /// <param name="dir1">The first observed direction</param>
 /// <param name="dir2">The second observed direction</param>
 internal IntersectTwoDirectionsOperation(Direction dir1, Direction dir2)
     : base()
 {
     m_Direction1 = dir1;
     m_Direction2 = dir2;
 }
        /// <summary>
        /// Displays info for a direction angle.
        /// </summary>
        /// <param name="dir">The direction to show.</param>
        void ShowAngle(Direction dir)
        {
            AngleDirection angle = (dir as AngleDirection);
            if (angle==null)
                return;

            // There should be no parallel points.
            m_Par1 = m_Par2 = null;

            // Get the backsight
            m_Backsight = angle.Backsight;
            ShowKey(backsightTextBox, m_Backsight);

            // Define the observed angle.
            m_Radians = angle.ObservationInRadians;
            m_IsClockwise = (m_Radians>=0.0);
            m_Radians = Math.Abs(m_Radians);

            string dirstr = RadianValue.AsString(m_Radians);
            if (angle is DeflectionDirection)
                dirstr += "d";
            directionTextBox.Text = dirstr;

            // Indicate whether it's clockwise or otherwise.
            clockwiseRadioButton.Enabled = counterClockwiseRadioButton.Enabled = true;

            if (m_IsClockwise)
            {
                clockwiseRadioButton.Checked = true;
                //counterClockwiseRadioButton.Checked = false;
            }
            else
            {
                //clockwiseRadioButton.Checked = false;
                counterClockwiseRadioButton.Checked = true;
            }
        }
Beispiel #8
0
        /// <summary>
        /// Intersects this direction with another direction.
        /// </summary>
        /// <param name="other">The other direction.</param>
        /// <returns>The calculated intersection (null if it doesn't exist)</returns>
        internal IPosition Intersect(Direction other)
        {
            // Get the starting positions for the two directions (may be offset).
            IPosition from1 = this.StartPosition;
            IPosition from2 = other.StartPosition;

            // Get the two directions in the form of a bearing.
            double b1 = this.Bearing.Radians;
            double b2 = other.Bearing.Radians;

            // The equation of each line is given in parametric form as:
            //
            //		x = xo + f * r
            //		y = yo + g * r
            //
            // where	xo,yo is the from point
            // and		f = sin(bearing)
            // and		g = cos(bearing)
            // and		r is the position ratio

            double cosb1 = Math.Cos(b1);
            double sinb1 = Math.Sin(b1);
            double cosb2 = Math.Cos(b2);
            double sinb2 = Math.Sin(b2);

            double f1g2 = sinb1 * cosb2;
            double f2g1 = sinb2 * cosb1;
            double det = f2g1 - f1g2;

            // Check whether lines are parallel.
            if (Math.Abs(det) < Double.Epsilon)
                return null;

            // Work out the intersection.

            double yo = from1.Y;
            double xo = from1.X;
            double dy = from2.Y - yo;
            double dx = from2.X - xo;
            double prat = (sinb2*dy - cosb2*dx)/det;
            return new Position((xo+sinb1*prat), (yo+cosb1*prat));
        }
Beispiel #9
0
        /// <summary>
        /// Relational equality test. When comparing any offsets, it's the actual ground
        /// dimension of the offset we're concerned with -- NOT the address of the offset,
        /// or the way it was specified (i.e. an offset can be the same, even if one is
        ///	an OffsetDistance, and the other is an OffsetPoint).
        ///	
        /// The result of the comparison is from the Direction class & down. Directions will
        /// compare the same, even if the info in parent classes is different.
        /// </summary>
        /// <param name="other">The direction to compare with</param>
        /// <returns></returns>
        internal bool IsEquivalent(Direction other)
        {
            // Check the simple fields.
            if (this.GetType() != other.GetType())
                return false;

            // If one direction has an offset & the other doesn't, the directions are different.

            if ( (m_Offset!=null && other.m_Offset==null) ||
                 (m_Offset==null && other.m_Offset!=null) )
                return false;

            //	If BOTH offsets are defined, see if they are equivalent.
            if (m_Offset!=null && other.m_Offset!=null )
            {
                // It is assumed that the point from which the direction
                // was measured has already been checked by the operator==
                // function in derived sub-classes.

                // Get the (signed) offsets, in meters on the ground.
                double offThis = m_Offset.GetMetric(this);
                double offThat = other.m_Offset.GetMetric(other);

                // The sign matters.
                if ((offThis<0.0 && offThat>=0.0) || (offThis>=0.0 && offThat<0.0))
                    return false;

                // Same sign, so if the offsets are the same, they should subtract to zero.
                if (Math.Abs(offThis-offThat) > Double.Epsilon)
                    return false;
            }

            // Return the result of comparing the two derived classes.
            // ...not sure what's going on here... (shouldn't this just call an abstract method? -- maybe
            // needs to be a templated method, since both types need to be the same.

            if (this is AngleDirection || this is DeflectionDirection)
            {
                AngleDirection rThis = (AngleDirection)this;
                AngleDirection rThat = (AngleDirection)other;
                return rThis.Equals(rThat);
            }
            else if (this is BearingDirection)
            {
                BearingDirection rThis = (BearingDirection)this;
                BearingDirection rThat = (BearingDirection)other;
                return rThis.Equals(rThat);
            }
            else if (this is ParallelDirection)
            {
                ParallelDirection rThis = (ParallelDirection)this;
                ParallelDirection rThat = (ParallelDirection)other;
                return rThis.Equals(rThat);
            }

            return false;
        }
 /// <summary>
 /// Calculates the intersection point.
 /// </summary>
 /// <param name="dir">Direction observation.</param>
 /// <param name="dist">Distance observation.</param>
 /// <param name="from">The point the distance was observed from.</param>
 /// <param name="usedefault">True if the default intersection is required (the one 
 /// closer to the origin of the direction line). False for the other one (if any).</param>
 /// <returns>The position of the intersection (null if it cannot be calculated).</returns>
 IPosition Calculate(Direction dir, Observation distance, PointFeature from, bool usedefault)
 {
     // Call the static function that is also used by the dialog.
     IPosition xsect, x1, x2;
     if (Calculate(dir, distance, from, usedefault, out xsect, out x1, out x2))
         return xsect;
     else
         return null;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="IntersectDirectionAndDistanceOperation"/> class
 /// </summary>
 /// <param name="dir">Direction observation.</param>
 /// <param name="dist">Distance observation.</param>
 /// <param name="from">The point the distance was observed from.</param>
 /// <param name="usedefault">True if the default intersection is required (the one 
 /// closer to the origin of the direction line). False for the other one (if any).</param>
 internal IntersectDirectionAndDistanceOperation(Direction dir, Observation dist, PointFeature from, bool useDefault)
     : base()
 {
     m_Direction = dir;
     m_Distance = dist;
     m_From = from;
     m_Default = useDefault;
 }
 /// <summary>
 /// Obtains update items for a revised version of this edit
 /// (for later use with <see cref="ExchangeData"/>).
 /// </summary>
 /// <param name="dist1">1st distance observation.</param>
 /// <param name="from1">The point the 1st distance was observed from.</param>
 /// <param name="dist2">2nd distance observation.</param>
 /// <param name="from2">The point the 2nd distance was observed from.</param>
 /// <param name="isdefault">True if the default intersection is required (the one that has the
 /// lowest bearing with respect to the 2 from points). False for the other one (if any).</param>
 /// <returns>The items representing the change (may be subsequently supplied to
 /// the <see cref="ExchangeUpdateItems"/> method).</returns>
 internal UpdateItemCollection GetUpdateItems(Direction dir, Observation distance,
     PointFeature from, bool isdefault)
 {
     UpdateItemCollection result = new UpdateItemCollection();
     result.AddObservation<Direction>(DataField.Direction, m_Direction, dir);
     result.AddObservation<Observation>(DataField.Distance, m_Distance, distance);
     result.AddFeature<PointFeature>(DataField.From, m_From, from);
     result.AddItem<bool>(DataField.Default, m_Default, isdefault);
     return result;
 }
        /// <summary>
        /// Calculates the intersection point.
        /// </summary>
        /// <param name="dir">Direction observation.</param>
        /// <param name="distance">Distance observation.</param>
        /// <param name="from">The point the distance was observed from.</param>
        /// <param name="usedefault">True if the default intersection is required (the one 
        /// closer to the origin of the direction line). False for the other one (if any).</param>
        /// <param name="xsect">The position of the intersection (if any).</param>
        /// <param name="xsect1">The 1st choice intersection (if any).</param>
        /// <param name="xsect2">The 2nd choice intersection (if any).</param>
        /// <returns>True if intersections were calculated. False if the distance circles
        /// don't intersect.</returns>
        internal static bool Calculate(Direction dir, Observation distance, PointFeature from, bool usedefault,
            out IPosition xsect, out IPosition xsect1, out IPosition xsect2)
        {
            // Initialize intersection positions.
            xsect = xsect1 = xsect2 = null;

            // Get the distance.
            double dist = distance.GetDistance(from).Meters;
            if (dist < Constants.TINY)
                return false;

            // Form circle with a radius that matches the observed distance.
            ICircleGeometry circle = new CircleGeometry(from, dist);

            // See if there is actually an intersection between the direction & the circle.
            IPosition x1, x2;
            uint nx = dir.Intersect(circle, out x1, out x2);
            if (nx==0)
                return false;

            // If we have 2 intersections, and we need the non-default one, pick up the 2nd
            // intersection. If only 1 intersection, use that, regardless of the setting for
            // the "use default" flag.

            if (nx==2 && !usedefault)
                xsect = x2;
            else
                xsect = x1;

            // Return if the distance is an offset point.
            OffsetPoint offset = (distance as OffsetPoint);

            if (offset!=null)
            {
                xsect1 = x1;
                xsect2 = x2;
                return true;
            }

            // Reduce observed distance to the mapping plane.
            ISpatialSystem sys = CadastralMapModel.Current.SpatialSystem;
            dist = dist * sys.GetLineScaleFactor(from, xsect);

            // And calculate the exact intersection (like above)...
            // Form circle with a radius that matches the reduced distance.
            ICircleGeometry circlep = new CircleGeometry(from, dist);

            // See if there is actually an intersection between the direction & the circle.
            nx = dir.Intersect(circlep, out x1, out x2);
            if (nx==0)
                return false;

            // If we have 2 intersections, and we need the non-default one, pick up the 2nd
            // intersection. If only 1 intersection, use that, regardless of the setting for
            // the "use default" flag.

            if (nx==2 && !usedefault)
                xsect = x2;
            else
                xsect = x1;

            xsect1 = x1;
            xsect2 = x2;

            return true;
        }
        /// <summary>
        /// Exchanges update items that were previously generated via
        /// a call to <see cref="GetUpdateItems"/>.
        /// </summary>
        /// <param name="data">The update data to apply to the edit (modified to
        /// hold the values that were previously defined for the edit)</param>
        public override void ExchangeData(UpdateItemCollection data)
        {
            m_Direction = data.ExchangeObservation<Direction>(this, DataField.Direction, m_Direction);
            m_Distance = data.ExchangeObservation<Observation>(this, DataField.Distance, m_Distance);
            m_From = data.ExchangeFeature<PointFeature>(this, DataField.From, m_From);
            m_Default = data.ExchangeValue<bool>(DataField.Default, m_Default);

            AssignObservedLengths();
        }
 /// <summary>
 /// Obtains update items for a revised version of this edit
 /// (for later use with <see cref="ExchangeData"/>).
 /// </summary>
 /// <param name="dir1">1st direction observation.</param>
 /// <param name="dir2">2nd direction observation.</param>
 /// <returns>The items representing the change (may be subsequently supplied to
 /// the <see cref="ExchangeUpdateItems"/> method).</returns>
 internal UpdateItemCollection GetUpdateItems(Direction dir1, Direction dir2)
 {
     UpdateItemCollection result = new UpdateItemCollection();
     result.AddObservation<Direction>(DataField.Direction1, m_Direction1, dir1);
     result.AddObservation<Direction>(DataField.Direction2, m_Direction2, dir2);
     return result;
 }
        /// <summary>
        /// Exchanges update items that were previously generated via
        /// a call to <see cref="GetUpdateItems"/>.
        /// </summary>
        /// <param name="data">The update data to apply to the edit (modified to
        /// hold the values that were previously defined for the edit)</param>
        public override void ExchangeData(UpdateItemCollection data)
        {
            m_Direction = data.ExchangeObservation<Direction>(this, DataField.Direction, m_Direction);
            m_Length = data.ExchangeObservation<Observation>(this, DataField.Length, m_Length);

            if (m_Line != null)
                m_Line.ObservedLength = (m_Length as Distance);
        }
 /// <summary>
 /// Reads data that was previously written using <see cref="WriteData"/>
 /// </summary>
 /// <param name="editDeserializer">The mechanism for reading back content.</param>
 /// <param name="dir1">The first observed direction.</param>
 /// <param name="dir2">The second observed direction</param>
 /// <param name="to">The created intersection point.</param>
 /// <param name="line1">The first line created (if any).</param>
 /// <param name="line1">The second line created (if any).</param>
 static void ReadData(EditDeserializer editDeserializer, out Direction dir1, out Direction dir2,
     out FeatureStub to, out FeatureStub line1, out FeatureStub line2)
 {
     dir1 = editDeserializer.ReadPersistent<Direction>(DataField.Direction1);
     dir2 = editDeserializer.ReadPersistent<Direction>(DataField.Direction2);
     to = editDeserializer.ReadPersistent<FeatureStub>(DataField.To);
     line1 = editDeserializer.ReadPersistentOrNull<FeatureStub>(DataField.Line1);
     line2 = editDeserializer.ReadPersistentOrNull<FeatureStub>(DataField.Line2);
 }
        /// <summary>
        /// Calculates the position of the sideshot point.
        /// </summary>
        /// <param name="dir">The direction observation (if any).</param>
        /// <param name="len">The length observation (if any). Could be a <c>Distance</c> or an
        /// <c>OffsetPoint</c>.</param>
        /// <returns>The position of the sideshot point (null if there is insufficient data
        /// to calculate a position)</returns>
        internal static IPosition Calculate(Direction dir, Observation len)
        {
            // Return if there is insufficient data.
            if (dir == null || len == null)
                return null;

            // Get the position of the point the sideshot should radiate from.
            PointFeature from = dir.From;

            // Get the position of the start of the direction line (which may be offset).
            IPosition start = dir.StartPosition;

            // Get the bearing of the direction.
            double bearing = dir.Bearing.Radians;

            // Get the length of the sideshot arm.
            double length = len.GetDistance(from).Meters;

            // Calculate the resultant position. Note that the length is the length along the
            // bearing -- if an offset was specified, the actual length of the line from-to =
            // sqrt(offset*offset + length*length)
            IPosition to = Geom.Polar(start, bearing, length);

            // Return if the length is an offset point. In that case, the length we have obtained
            // is already a length on the mapping plane, so no further reduction should be done
            // (although it's debateable).
            if (len is OffsetPoint)
                return to;

            // Using the position we've just got, reduce the length we used to a length on the
            // mapping plane (it's actually a length on the ground).
            ISpatialSystem sys = CadastralMapModel.Current.SpatialSystem;
            double sfac = sys.GetLineScaleFactor(start, to);
            return Geom.Polar(start, bearing, length * sfac);
        }
        /// <summary>
        /// Displays info for a specific direction and line.
        /// </summary>
        /// <param name="dir">The direction to show.</param>
        /// <param name="line">The line to show (null if there is no line).</param>
        void Show(Direction dir, LineFeature line)
        {
            // If we have a line, define its entity type and scroll the
            // entity combo box to that type. Note that when the string
            // is selected, it is important that m_Dir is null; otherwise
            // <mf CdGetDir::OnSelChangeLineType> may automatically move
            // on to the next page of the wizard dialog.

            m_LineType = (line==null ? null : line.EntityType);
            lineTypeComboBox.SelectEntity(m_LineType);

            // Define the from-point of the direction.
            m_From = dir.From;
            ShowKey(fromPointTextBox, m_From);

            // Ensure we've got any circle info.
            GetCircles();

            // Does the direction have an offset?
            Offset offset = dir.Offset;
            if (offset!=null)
                ShowOffset(dir);

            // The rest depends on what sort of direction we have.
            if (dir is BearingDirection)
                ShowBearing(dir);
            else if (dir is AngleDirection) // Deflection too
                ShowAngle(dir);
            else if (dir is ParallelDirection)
                ShowParallel(dir);
            else
                MessageBox.Show("GetDirectionControl.Show - Cannot display direction info.");
        }
 /// <summary>
 /// Obtains update items for a revised version of this edit
 /// (for later use with <see cref="ExchangeData"/>).
 /// </summary>
 /// <param name="dir">The direction (could contain an offset).</param>
 /// <param name="length">The length of the sideshot arm (either a <see cref="Distance"/>
 /// or an <see cref="OffsetPoint"/>).</param>
 /// <returns>The items representing the change (may be subsequently supplied to
 /// the <see cref="ExchangeUpdateItems"/> method).</returns>
 internal UpdateItemCollection GetUpdateItems(Direction dir, Observation length)
 {
     UpdateItemCollection result = new UpdateItemCollection();
     result.AddObservation<Direction>(DataField.Direction, m_Direction, dir);
     result.AddObservation<Observation>(DataField.Length, m_Length, length);
     return result;
 }
        /// <summary>
        /// Displays info for a direction bearing.
        /// </summary>
        /// <param name="dir">The direction to show.</param>
        void ShowBearing(Direction dir)
        {
            BearingDirection bearing = (dir as BearingDirection);
            if (bearing==null)
                return;

            // There should be nothing in the backsight field.
            m_Backsight = m_Par1 = m_Par2 = null;

            // Define the bearing.
            m_Radians = bearing.Bearing.Radians;
            directionTextBox.Text = RadianValue.AsString(m_Radians);

            // Always comes back clockwise.
            m_IsClockwise = true;
            clockwiseRadioButton.Enabled = counterClockwiseRadioButton.Enabled = true;
            counterClockwiseRadioButton.Checked = false;
            clockwiseRadioButton.Checked = true;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RadialOperation"/> class.
 /// </summary>
 /// <param name="dir">The direction (could contain an offset).</param>
 /// <param name="length">The length of the sideshot arm (either a <see cref="Distance"/> or
 /// an <see cref="OffsetPoint"/>).</param>
 internal RadialOperation(Direction dir, Observation length)
     : base()
 {
     m_Direction = dir;
     m_Length = length;
 }
        /// <summary>
        /// Displays info for a direction defined as parallel to 2 other points.
        /// </summary>
        /// <param name="dir">The direction to show.</param>
        void ShowParallel(Direction dir)
        {
            ParallelDirection par = (dir as ParallelDirection);
            if (par==null)
                return;

            // Pick up the points that define the parallel.
            m_Par1 = par.Start;
            m_Par2 = par.End;

            // Display the IDs of the 2 points.
            directionTextBox.Text = String.Format("{0}->{1}", m_Par1.FormattedKey, m_Par2.FormattedKey);

            // Disallow the ability to say whether the direction is clockwise or otherwise.
            TurnRadioOff(clockwiseRadioButton);
            TurnRadioOff(counterClockwiseRadioButton);

            // The angle value should be undefined.
            m_Radians = 0.0;
            m_IsClockwise = true;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RadialOperation"/> class
        /// using the data read from persistent storage.
        /// </summary>
        /// <param name="editDeserializer">The mechanism for reading back content.</param>
        internal RadialOperation(EditDeserializer editDeserializer)
            : base(editDeserializer)
        {
            m_Direction = editDeserializer.ReadPersistent<Direction>(DataField.Direction);
            m_Length = editDeserializer.ReadPersistent<Observation>(DataField.Length);

            DeserializationFactory dff = new DeserializationFactory(this);
            dff.AddFeatureStub(DataField.To, editDeserializer.ReadPersistent<FeatureStub>(DataField.To));
            dff.AddFeatureStub(DataField.Line, editDeserializer.ReadPersistentOrNull<FeatureStub>(DataField.Line));
            ProcessFeatures(dff);
        }
        /// <summary>
        /// Initializes dialog for an update.
        /// </summary>
        /// <param name="op">The edit that is being updated or recalled</param>
        /// <param name="dir">The direction number (1 or 2). A value of 2 is only
        /// valid when dealing with the <see cref="IntersectTwoDirectionsForm"/> dialog.</param>
        /// <returns>True if update (or recalled command) was shown.</returns>
        bool ShowUpdate(IntersectOperation op, byte dir)
        {
            /*
            //	Return if no update feature (and no recall op).
            const CeIntersect* pop = GetUpdateOp();
            if ( pop==0 ) pop = GetRecall();
            if ( !pop ) return FALSE;
             */

            if (op==null)
                return false;

            // Ensure that there is no direction line. If you don't do
            // this, it is possible that when we select a string in the
            // entity combo, we'll move directly to the next page of the
            // dialog (see <mf CdGetDir::OnSelChangeLineType>).
            m_Dir = null;

            // Populate the dialog, depending on what sort of operation we have.
            if (op.EditId == EditingActionId.DirIntersect)
            {
                Debug.Assert(dir==1 || dir==2);
                IntersectTwoDirectionsOperation oper = (IntersectTwoDirectionsOperation)op;

                if (dir==1)
                    Show(oper.Direction1, oper.CreatedLine1);
                else
                    Show(oper.Direction2, oper.CreatedLine2);
            }
            else if (op.EditId == EditingActionId.DirDistIntersect)
            {
                IntersectDirectionAndDistanceOperation oper = (IntersectDirectionAndDistanceOperation)op;
                Show(oper.Direction, oper.CreatedDirectionLine);
            }
            else if (op.EditId == EditingActionId.DirLineIntersect)
            {
                IntersectDirectionAndLineOperation oper = (IntersectDirectionAndLineOperation)op;
                Show(oper.Direction, oper.CreatedDirectionLine);
            }
            else
            {
                MessageBox.Show("GetDirectionControl.ShowUpdate - Unexpected editing operation");
            }

            // Ensure everything is drawn ok.
            // this->OnDrawAll();

            // Disallow change of line type (you cannot add or delete lines via update).
            lineTypeGroupBox.Enabled = false;

            return true;
        }
        /// <summary>
        /// Returns the offset distance with respect to a reference direction, in meters
        /// on the ground. Offsets to the left are returned as a negated value, while
        /// offsets to the right are positive values.
        /// </summary>
        /// <param name="dir">The direction that the offset was observed with respect to.</param>
        /// <returns>The signed offset distance, in meters on the ground.</returns>
        internal override double GetMetric(Direction dir)
        {
            // In the case of an offset distance, the reference direction
            // is not actually required to get the offset (it is required
            // as a parameter only because the base class defines a pure
            // virtual this way).

            return this.Meters;
        }
 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>
 /// Exchanges update items that were previously generated via
 /// a call to <see cref="GetUpdateItems"/>.
 /// </summary>
 /// <param name="data">The update data to apply to the edit (modified to
 /// hold the values that were previously defined for the edit)</param>
 public override void ExchangeData(UpdateItemCollection data)
 {
     m_Direction1 = data.ExchangeObservation<Direction>(this, DataField.Direction1, m_Direction1);
     m_Direction2 = data.ExchangeObservation<Direction>(this, DataField.Direction2, m_Direction2);
 }
Beispiel #29
0
 /// <summary>
 /// Returns the offset distance with respect to a reference direction, in meters
 /// on the ground. Offsets to the left are returned as a negated value, while
 /// offsets to the right are positive values.
 /// </summary>
 /// <param name="dir">The direction that the offset was observed with respect to.</param>
 /// <returns>The signed offset distance, in meters on the ground</returns>
 internal abstract double GetMetric(Direction dir);
Beispiel #30
0
        /// <summary>
        /// Returns the offset distance with respect to a reference direction, in meters
        /// on the ground. Offsets to the left are returned as a negated value, while
        /// offsets to the right are positive values.
        /// </summary>
        /// <param name="dir">The direction that the offset was observed with respect to.</param>
        /// <returns>The signed offset distance, in meters on the ground</returns>
        internal override double GetMetric(Direction dir)
        {
            // Return offset of zero if there is no offset point.
            if (m_Point==null)
                return 0.0;

            // Get the origin of the direction & it's bearing. This gives
            // us the info we need to express the equation of the line
            // in parametric form.

            PointFeature from = dir.From;
            double x = from.X;
            double y = from.Y;
            double bearing = dir.Bearing.Radians;

            // Get the position of the offset point.
            double xoff = m_Point.X;
            double yoff = m_Point.Y;

            // Get the signed perpendicular distance from the offset
            // point to the reference direction.
            return BasicGeom.SignedDistance(x, y, bearing, xoff, yoff);
        }