Пример #1
0
        /// <summary>
        /// Obtains the control points that need to be imported
        /// </summary>
        /// <returns>The points to save</returns>
        ControlPoint[] GetSavePoints()
        {
            List <ControlPoint> result = new List <ControlPoint>();
            ISpatialIndex       index  = CadastralMapModel.Current.EditingIndex;

            foreach (ControlRange r in m_Ranges)
            {
                ControlPoint[] cps = r.GetDefinedPoints();

                foreach (ControlPoint p in cps)
                {
                    if (p.IsDefined)
                    {
                        // Ignore the point if it already exists as part of the map (same position, same foreign ID).
                        PointFeature xp         = (index.QueryClosest(p, Length.Zero, SpatialType.Point) as PointFeature);
                        bool         isExisting = (xp != null && xp.IsForeignId && xp.FormattedKey == p.ControlId.ToString());
                        if (!isExisting)
                        {
                            result.Add(p);
                        }
                    }
                }
            }

            return(result.ToArray());
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ParallelDirection"/> class
 /// using the data read from persistent storage.
 /// </summary>
 /// <param name="editDeserializer">The mechanism for reading back content.</param>
 internal ParallelDirection(EditDeserializer editDeserializer)
     : base(editDeserializer)
 {
     m_From = editDeserializer.ReadFeatureRef<PointFeature>(this, DataField.From);
     m_Par1 = editDeserializer.ReadFeatureRef<PointFeature>(this, DataField.Start);
     m_Par2 = editDeserializer.ReadFeatureRef<PointFeature>(this, DataField.End);
 }
Пример #3
0
 /// <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);
 }
Пример #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="cc">Object for holding any displayed dialogs</param>
 /// <param name="action">The action that initiated this command</param>
 /// <param name="start">Point initially selected at start of command</param>
 internal NewLineUI(IControlContainer cc, IUserAction action, PointFeature start)
     : base(cc, action)
 {
     m_Start = start;
     m_End = null;
     m_CurrentPoint = start;
 }
Пример #5
0
        /// <summary>
        /// Starts the user interface (if any) for this command.
        /// </summary>
        /// <returns>True if command started ok.</returns>
        internal override bool Run()
        {
            // Don't run more than once.
            if (m_Dialog != null)
            {
                throw new InvalidOperationException("RadialUI.Run - Command is already running.");
            }

            UpdateUI pup = this.Update;

            if (pup != null)
            {
                m_Dialog = new RadialControl(pup);
            }
            else
            {
                if (m_From == null)
                {
                    RadialOperation recall = (RadialOperation)this.Recall;
                    m_From = recall.From;
                }

                m_Dialog = new RadialControl(this, m_From);
            }

            this.Container.Display(m_Dialog);
            return(true);
        }
Пример #6
0
        private void radiusTextBox_TextChanged(object sender, EventArgs e)
        {
            string str = radiusTextBox.Text.Trim();

            if (str.Length == 0)
            {
                // If we already had radius info, reset it.
                SetNormalColor(m_RadiusPoint);
                m_RadiusPoint    = null;
                m_RadiusDistance = null;
                OnChange();
            }
            else
            {
                // If the first character is a "+" character, it means the text was set
                // via a pointing operation. So if the first char is NOT a "+", treat it
                // as an entered radius.
                if (str[0] != '+')
                {
                    SetNormalColor(m_RadiusPoint);
                    m_RadiusPoint = null;
                    ParseRadius();
                }
            }
        }
Пример #7
0
        internal void SelectPoint(PointFeature point)
        {
            // Get rid of any parallel already drawn.
            KillParallel();

            // Get rid of any previously entered distance.
            m_Offset = null;

            // Remember the selected point.
            m_Point = point;

            // If it's actually defined, re-draw the parallel and display
            // the key of the point.
            if (m_Point != null)
            {
                // Calculate the parallel and draw it.
                Calculate();
                Draw();

                // Display the key of the offset point. This will call
                // the OnChange handler for the field.
                string keystr = String.Format("+{0}", m_Point.FormattedKey);
                offsetTextBox.Text = keystr;
            }
            else
            {
                // Disable the "other way" button.
                otherWayButton.Enabled = false;

                // Ensure the offset field is blank.
                offsetTextBox.Text = String.Empty;
            }
        }
Пример #8
0
        /// <summary>
        /// Parses an explicitly entered offset distance.
        /// </summary>
        /// <returns>True if offset parses ok.</returns>
        bool ParseOffset()
        {
            // Get the entered string.
            string str = offsetTextBox.Text.Trim();

            // Try to parse it.
            Distance offdist = new Distance(str);

            if (!offdist.IsDefined)
            {
                MessageBox.Show("Invalid offset distance");
                return(false);
            }

            // Hold on to the parsed offset
            m_Offset = offdist;

            // Any previously specified offset point is irrelevant.
            if (m_Point != null)
            {
                m_Cmd.ErasePainting();
                m_Point = null;
            }

            return(true);
        }
Пример #9
0
        /// <summary>
        /// Attempts to calculate the position of the intersect, using the currently
        /// entered information.
        /// </summary>
        /// <returns>The position of the intersect (null if there isn't one)</returns>
        internal override IPosition CalculateIntersect()
        {
            Observation  dist1 = getDistance1.ObservedDistance;
            PointFeature from1 = getDistance1.From;

            if (from1 == null || dist1 == null)
            {
                return(null);
            }

            Observation  dist2 = getDistance2.ObservedDistance;
            PointFeature from2 = getDistance2.From;

            if (from2 == null || dist2 == null)
            {
                return(null);
            }

            bool isdefault = intersectInfo.IsDefault;

            IPosition xsect, xsect1, xsect2;

            if (IntersectTwoDistancesOperation.Calculate(dist1, from1, dist2, from2, isdefault,
                                                         out xsect, out xsect1, out xsect2))
            {
                return(xsect);
            }

            return(null);
        }
Пример #10
0
        private void offsetTextBox_TextChanged(object sender, EventArgs e)
        {
            // Ensure there is no parallel displayed.
            KillParallel();

            if (offsetTextBox.Text.Length == 0)
            {
                // If we already had offset info, reset it.
                m_Point  = null;
                m_Offset = null;

                // Disable the "other way" button.
                otherWayButton.Enabled = false;
            }
            else
            {
                // The offset could have been specified by the user, or it could have
                // been set as the result of a pointing operation. In the latter case,
                // m_Point will be defined.

                if (m_Point == null)
                {
                    ParseOffset();

                    // Enable the "other way" button if we've got an offset.
                    if (m_Offset != null)
                    {
                        otherWayButton.Enabled = true;
                    }
                }
                else
                {
                    // Confirm that the displayed text is the text that was
                    // added by SelectPoint. If not, the user may be trying
                    // to type in a offset. Permit fewer chars, in case the
                    // user is erasing.

                    string keystr = String.Format("+{0}", m_Point.FormattedKey);
                    string curstr = offsetTextBox.Text;
                    if (curstr.Length > keystr.Length)
                    {
                        string msg = String.Empty;
                        msg += ("What are you trying to do? If you want to type in a" + System.Environment.NewLine);
                        msg += ("new offset, you must initially delete the point ID" + System.Environment.NewLine);
                        msg += ("that is currently displayed.");
                        MessageBox.Show(msg);
                        return;
                    }

                    // Disable the "other way" button.
                    otherWayButton.Enabled = false;
                }
            }

            // Try calculating the parallel. On success, draw it.
            if (Calculate())
            {
                Draw();
            }
        }
Пример #11
0
        /// <summary>
        /// Obtains the features along this face that were created by a specific edit.
        /// </summary>
        /// <param name="edit">The edit of interest</param>
        /// <param name="parentLine">The line that was subdivided</param>
        /// <returns>The new features created to represent the sections of this face.</returns>
        internal Feature[] GetFeaturesCreatedBy(Operation edit)
        {
            if (m_Sections == null)
            {
                return(new Feature[0]);
            }

            List <Feature> result = new List <Feature>();

            foreach (LineFeature line in m_Sections)
            {
                // Append point feature at the end of the section (so long as it was created
                // by the specified edit).
                PointFeature pf = line.EndPoint;
                if (pf.Creator == edit)
                {
                    result.Add(pf);
                }

                if (line.Creator == edit)
                {
                    result.Add(line);
                }
            }

            return(result.ToArray());
        }
Пример #12
0
        /// <summary>
        /// Performs the data processing associated with this face.
        /// </summary>
        /// <param name="parentLine">The line that is being subdivided</param>
        /// <param name="ctx">The context in which the geometry is being calculated.</param>
        internal void CalculateGeometry(LineFeature parentLine, EditingContext ctx)
        {
            // Get adjusted lengths for each section
            double[] adjray = GetAdjustedLengths(parentLine, m_Distances);

            double       edist    = 0.0; // Distance to end of section.
            PointFeature start    = parentLine.StartPoint;
            LineGeometry lineGeom = parentLine.LineGeometry;

            for (int i = 0; i < adjray.Length; i++)
            {
                // Calculate the position at the end of the span
                edist += adjray[i];
                IPosition to;
                if (!lineGeom.GetPosition(new Length(edist), out to))
                {
                    throw new Exception("Cannot adjust line section");
                }

                // Get the point feature at the end of the span
                LineFeature  line = m_Sections[i];
                PointFeature end  = line.EndPoint;

                // Assign the calculated position so long as we're not at
                // the end of the line
                if (end != parentLine.EndPoint)
                {
                    end.ApplyPointGeometry(ctx, PointGeometry.Create(to));
                }

                // The end of the current span is the start of the next one
                start = end;
            }
        }
Пример #13
0
        internal override void OnDraw(PointFeature point)
        {
            getDistance1.OnDrawAll();
            getDistance2.OnDrawAll();

            if (intersectInfo.Visible)
            {
                intersectInfo.OnDraw();

                IPosition x = intersectInfo.Intersection;
                if (x != null)
                {
                    ISpatialDisplay display = GetCommand().ActiveDisplay;
                    IDrawStyle      style   = EditingController.Current.Style(Color.Magenta);

                    if (getDistance1.LineType != null)
                    {
                        PointFeature p = getDistance1.From;
                        style.Render(display, new IPosition[] { p, x });
                    }

                    if (getDistance2.LineType != null)
                    {
                        PointFeature p = getDistance2.From;
                        style.Render(display, new IPosition[] { p, x });
                    }
                }
            }
        }
Пример #14
0
        /// <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;
        }
        /// <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);
        }
Пример #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ParallelDirection"/> class
 /// using the data read from persistent storage.
 /// </summary>
 /// <param name="editDeserializer">The mechanism for reading back content.</param>
 internal ParallelDirection(EditDeserializer editDeserializer)
     : base(editDeserializer)
 {
     m_From = editDeserializer.ReadFeatureRef <PointFeature>(this, DataField.From);
     m_Par1 = editDeserializer.ReadFeatureRef <PointFeature>(this, DataField.Start);
     m_Par2 = editDeserializer.ReadFeatureRef <PointFeature>(this, DataField.End);
 }
Пример #17
0
        private void radiusTextBox_Leave(object sender, EventArgs e)
        {
            // No validation if the radius is being specified by pointing (in
            // that case, losing the focus is ok.
            if (m_RadiusPoint != null)
            {
                OnChange();
                return;
            }

            // Return if the field is empty.
            string str = radiusTextBox.Text.Trim();

            if (str.Length == 0)
            {
                OnChange();
                return;
            }

            // If the field starts with a "+" character, it must be
            // an explicitly entered point ID.
            if (str[0] == '+')
            {
                m_RadiusPoint = GetPoint(radiusTextBox);
                if (m_RadiusPoint == null)
                {
                    radiusTextBox.Focus();
                    return;
                }
            }

            // Parse the radius.
            ParseRadius();
        }
Пример #18
0
        /// <summary>
        /// Draws the supplied point with a color that's consistent with the
        /// meaning of a control appearing on this dialog.
        /// </summary>
        /// <param name="point">The point to draw</param>
        /// <param name="field">The control the point relates to
        /// (default was the field that currently has the focus)
        /// </param>
        void SetColor(PointFeature point, Control field)
        {
            // Return if point not specified.
            if (point == null)
            {
                return;
            }

            // Determine the color.
            Color col;

            if (field == fromPointTextBox)
            {
                col = Color.Cyan;
            }
            else if (field == distanceTextBox)
            {
                col = Color.Yellow;
            }
            else
            {
                return;
            }

            // Draw the point in the proper color.
            point.Draw(ActiveDisplay, col);
        }
Пример #19
0
        void InitUpdate(LineExtensionOperation pop)
        {
            Form parent = ParentForm;

            parent.Text = "Update Line Extension";

            m_ExtendLine      = pop.ExtendedLine;
            m_IsExtendFromEnd = pop.IsExtendFromEnd;
            m_Length          = new Distance(pop.Length);

            // Was an extension line added?
            m_WantLine = (pop.NewLine != null);

            // Scroll the entity combo to the previously defined
            // entity type for the extension point.
            PointFeature point = pop.NewPoint;
            IEntity      ent   = point.EntityType;

            if (ent != null)
            {
                pointTypeComboBox.SelectEntity(ent);
            }

            // Display the original observed length.
            lengthTextBox.Text = m_Length.Format();

            // Display the point key (if any)
            idComboBox.DropDownStyle = ComboBoxStyle.DropDown;
            idComboBox.Text          = point.FormattedKey;
        }
Пример #20
0
        private static IFeature CreateFeatureWithColors()
        {
            var featureWithColors = new PointFeature(new MPoint(0, -7000000));

            featureWithColors.Styles.Add(CreateColoredLabelStyle());
            return(featureWithColors);
        }
Пример #21
0
 /// <summary>
 /// Does any command-specific drawing.
 /// </summary>
 /// <param name="point">The specific point (if any) that the parent window has drawn. Not used.</param>
 internal override void Paint(PointFeature point)
 {
     if (m_Dialog != null)
     {
         m_Dialog.Draw(point);
     }
 }
Пример #22
0
        /// <summary>
        /// Corrects this operation.
        /// </summary>
        /// <param name="center">The point at the center of the circle.</param>
        /// <param name="radius">The radius of the circle (either a <see cref="Distance"/> object,
        /// or an <see cref="OffsetPoint"/> that sits on the circumference of the circle.</param>
        /// <returns>True if operation updated ok.</returns>
        internal bool Correct(PointFeature center, Observation radius)
        {
            throw new NotImplementedException();

            /*
             * // If the center point has changed, cut the reference to this
             * // operation from the old point, and change it so the
             * // operation is referenced from the new center.
             * if (!Object.ReferenceEquals(m_Center, center))
             * {
             *  m_Center.CutOp(this);
             *  m_Center = center;
             *  m_Center.AddOp(this);
             * }
             *
             * // If the old radius observation refers to an offset point, cut
             * // the reference that the point has to this op. If nothing has
             * // changed, the reference will be re-inserted when the
             * // observation is re-saved below.
             * CutOffsetRef(m_Radius);
             *
             * // Get rid of the previously defined observation, and replace
             * // with the new one (we can't necessarily change the old one
             * // because we may have changed the type of observation).
             *
             * m_Radius.OnRollback(this);
             * m_Radius = radius;
             * m_Radius.AddReferences(this);
             *
             * return true;
             */
        }
Пример #23
0
        /// <summary>
        /// Performs the data processing associated with this editing operation.
        /// </summary>
        /// <param name="ctx">The context in which the geometry is being calculated.</param>
        internal override void CalculateGeometry(EditingContext ctx)
        {
            // Get the radius, in meters on the ground.
            double rad = m_Radius.GetDistance(m_Center).Meters;

            if (rad < Constants.TINY)
            {
                throw new Exception("NewCircleOperation.CalculateGeometry - Radius is too close to zero.");
            }

            // If the closing point was created by this edit, define it's position
            ArcFeature   arc = (ArcFeature)this.Line;
            PointFeature p   = arc.StartPoint;

            if (p.Creator == this)
            {
                PointGeometry pg = new PointGeometry(m_Center.X, m_Center.Y + rad);
                p.ApplyPointGeometry(ctx, pg);
            }

            // Define the radius of the circle and include in the map model
            Circle circle = arc.Circle;

            Debug.Assert(circle != null);
            circle.Radius = rad;

            // Refer the center point to the circle.
            circle.AddReferences();
        }
Пример #24
0
 /// <summary>
 /// Reacts to the selection of a point feature.
 /// </summary>
 /// <param name="point">The point (if any) that has been selected.</param>
 internal override void OnSelectPoint(PointFeature point)
 {
     if (m_Dialog != null)
     {
         m_Dialog.OnSelectPoint(point);
     }
 }
Пример #25
0
        /// <inheritdoc />
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            GH_ObjectWrapper goo = null;

            if (!DA.GetData(0, ref goo))
            {
                return;
            }

            IFeature feat = null;

            switch (goo.Value)
            {
            case Mesh m:
                feat = new MeshFeature(m);
                break;

            case Curve c:
                feat = new CurveFeature(c);
                break;

            case Point3d p:
                feat = new PointFeature(p);
                break;

            default:
                throw new ArgumentException();
            }

            DA.SetData(0, new GH_ObjectWrapper(feat));
        }
Пример #26
0
        /// <summary>
        /// Performs data processing that involves creating or retiring spatial features.
        /// Newly created features will not have any definition for their geometry - a
        /// subsequent call to <see cref="CalculateGeometry"/> is needed to to that.
        /// </summary>
        /// <param name="ff">The factory class for generating any spatial features</param>
        internal override void ProcessFeatures(FeatureFactory ff)
        {
            // If the closing point does not already exist, create one at some unspecified position
            OffsetPoint  offset = (m_Radius as OffsetPoint);
            PointFeature p      = (offset == null ? null : offset.Point);

            if (p == null)
            {
                p = ff.CreatePointFeature(DataField.ClosingPoint);
            }

            // Form the construction line (there is no associated circle at this stage, because
            // geometry does not get created until CalculateGeometry)
            ArcFeature arc = ff.CreateArcFeature(DataField.Arc, p, p);

            // Attach a new circle with undefined radius (at this stage, we do NOT cross-reference
            // it to the center point or add it to the map model, since that should be left unti;
            // CalculateGeometry).

            // Note: Setting the arc geometry also updates the circle to refer back to the feature.

            var circle = new Circle(m_Center, 0.0);

            arc.Geometry = new ArcGeometry(circle, arc.StartPoint, arc.StartPoint, true);

            base.SetNewLine(arc);
        }
Пример #27
0
        public void AddValueToField(PointFeature featureData)
        {
            OSGeo.OGR.Feature feature = new OSGeo.OGR.Feature(_ogrLayer.GetLayerDefn());

            feature.SetField(nameof(featureData.SampleId), featureData.SampleId);
            feature.SetField(nameof(featureData.Confidence), featureData.Confidence);
            feature.SetField(nameof(featureData.AgreeingValidations), featureData.AgreeingValidations);
            feature.SetField(nameof(featureData.UserConf), featureData.UserConf);

            feature.SetField(nameof(featureData.ValidityTime),
                             featureData.ValidityTime != null ? featureData.ValidityTime.Value.ToString("yyyy-MM-dd") : "");

            feature.SetField(nameof(featureData.ImageryTime),
                             featureData.ImageryTime != null ? featureData.ImageryTime.Value.ToString("yyyy-MM-dd") : "");

            feature.SetField(nameof(featureData.ValidationTime),
                             featureData.ValidationTime != null ? featureData.ValidationTime.Value.ToString("yyyy-MM-dd") : "");

            feature.SetField(nameof(featureData.LandCover), featureData.LandCover);
            feature.SetField(nameof(featureData.CropType1), featureData.CropType1);
            feature.SetField(nameof(featureData.CropType2), featureData.CropType2);
            feature.SetField(nameof(featureData.Irrigation1), featureData.Irrigation1);
            feature.SetField(nameof(featureData.Irrigation2), featureData.Irrigation2);
            feature.SetField(nameof(featureData.Irrigation3), featureData.Irrigation3);
            feature.SetField(nameof(featureData.ExtendedData), featureData.ExtendedData);

            Geometry geometry = Geometry.CreateFromWkt($"POINT({featureData.Geometry.X} {featureData.Geometry.Y})");

            feature.SetGeometry(geometry);

            _ogrLayer.CreateFeature(feature);
        }
Пример #28
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="from">The point the direction is from.</param>
 /// <param name="par1">The first point in the definition of the parallel line.</param>
 /// <param name="par2">The second point defining the parallel line.</param>
 internal ParallelDirection(PointFeature from, PointFeature par1, PointFeature par2)
     : base()
 {
     m_From = from;
     m_Par1 = par1;
     m_Par2 = par2;
 }
Пример #29
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="from">The point the direction is from.</param>
 /// <param name="par1">The first point in the definition of the parallel line.</param>
 /// <param name="par2">The second point defining the parallel line.</param>
 internal ParallelDirection(PointFeature from, PointFeature par1, PointFeature par2)
     : base()
 {
     m_From = from;
     m_Par1 = par1;
     m_Par2 = par2;
 }
Пример #30
0
        private static PointFeature CreatePoint(double x, double y, IStyle style)
        {
            var result = new PointFeature(new MPoint(x, y));

            result.Styles.Add(style);
            return(result);
        }
Пример #31
0
        /// <summary>
        /// Attempts to calculate the position of the intersect, using the currently
        /// entered information.
        /// </summary>
        /// <returns>The position of the intersect (null if there isn't one)</returns>
        internal override IPosition CalculateIntersect()
        {
            Direction dir = getDirection.Direction;

            if (dir == null)
            {
                return(null);
            }

            LineFeature line = getLine.Line;

            if (line == null)
            {
                return(null);
            }

            // The closest point may be null if the finish page has never been shown
            PointFeature closeTo = intersectInfo.ClosestPoint;
            IPosition    xsect;
            PointFeature closest;

            dir.Intersect(line, closeTo, out xsect, out closest);
            return(xsect);

            /*
             *
             * // If we got an intersection, and we did not previously have
             * // a close-to point, define that now.
             * if (ok && !m_pCloseTo)
             * {
             *  m_pCloseTo = pClosest;
             *  ShowCloseTo();
             * }
             */
        }
Пример #32
0
        /// <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);
        }
Пример #33
0
        /// <summary>
        /// Calculates positions that are parallel to a line.
        /// </summary>
        /// <param name="line">The reference line.</param>
        /// <param name="offset">The observed offset (either a <c>Distance</c> or an <c>OffsetPoint</c>).</param>
        /// <param name="sres">The position of the start of the parallel.</param>
        /// <param name="eres">The position of the end of the parallel.</param>
        /// <returns>True if positions calculated ok</returns>
        internal static bool Calculate(LineFeature line, Observation offset, out IPosition sres, out IPosition eres)
        {
            sres = eres = null;

            // Can't calculate if there is insufficient data.
            if (line == null || offset == null)
            {
                return(false);
            }

            // Is it an observed distance?
            Distance dist = (offset as Distance);

            if (dist != null)
            {
                return(ParallelLineUI.Calculate(line, dist, out sres, out eres));
            }

            // The only other thing it could be is an offset point.
            OffsetPoint offPoint = (offset as OffsetPoint);

            if (offPoint != null)
            {
                PointFeature point = offPoint.Point;
                return(ParallelLineUI.Calculate(line, point, out sres, out eres));
            }

            MessageBox.Show("ParallelLineUI.Calculate - Unexpected sort of observation");
            return(false);
        }
        /// <summary>
        /// Attempts to calculate the position of the intersect, using the currently
        /// entered information.
        /// </summary>
        /// <returns>The position of the intersect (null if there isn't one)</returns>
        internal override IPosition CalculateIntersect()
        {
            Direction dir = getDirection.Direction;

            if (dir == null)
            {
                return(null);
            }

            Observation  dist = getDistance.ObservedDistance;
            PointFeature from = getDistance.From;

            if (dist == null || from == null)
            {
                return(null);
            }

            bool isdefault = intersectInfo.IsDefault;

            IPosition xsect, xsect1, xsect2;

            if (IntersectDirectionAndDistanceOperation.Calculate(dir, dist, from, isdefault,
                                                                 out xsect, out xsect1, out xsect2))
            {
                return(xsect);
            }

            return(null);
        }
Пример #35
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="cc">Object for holding any displayed dialogs</param>
 /// <param name="action">The action that initiated this command</param>
 /// <param name="start">Point initially selected at start of command</param>
 internal NewCircularArcUI(IControlContainer cc, IUserAction action, PointFeature start)
     : base(cc, action, start)
 {
     m_IsShortArc = true;
     m_Circles = null;
     m_NewArcCircle = null;
     m_Geom = null;
 }
Пример #36
0
        internal InverseDistanceForm()
        {
            InitializeComponent();
            color1Button.BackColor = InverseColors[0];
            color2Button.BackColor = InverseColors[1];

            m_Point1 = m_Point2 = null;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AttachPointOperation"/> class.
        /// </summary>
        /// <param name="line">The line the point should appear on.</param>
        /// <param name="positionRatio">The position ratio of the attached point. A point coincident with the start
        /// of the line is a value of 0. A point at the end of the line is a value of
        /// 1 billion  (1,000,000,000).</param>
        internal AttachPointOperation(LineFeature line, uint positionRatio)
            : base()
        {
            if (line == null)
                throw new ArgumentNullException();

            m_Line = line;
            m_PositionRatio = positionRatio;
            m_Point = null;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LineExtensionOperation"/> class
        /// </summary>
        /// <param name="extendLine">The line that's being extended.</param>
        /// <param name="isFromEnd">True if extending from the end | False from the start.</param>
        /// <param name="length">The length of the extension.</param>
        internal LineExtensionOperation(LineFeature extendLine, bool isFromEnd, Distance length)
            : base()
        {
            m_ExtendLine = extendLine;
            m_IsExtendFromEnd = isFromEnd;
            m_Length = length;

            m_NewLine = null;
            m_NewPoint = null;
        }
        public InverseDistanceAngleForm()
        {
            InitializeComponent();
            color1Button.BackColor = InverseColors[0];
            color2Button.BackColor = InverseColors[1];
            color3Button.BackColor = InverseColors[2];

            m_Point1 = m_Point2 = m_Point3 = null;
            m_Clockwise = true;
        }
Пример #40
0
        /// <summary>
        /// Constructor for performing a sideshot from the currently selected point.
        /// </summary>
        /// <param name="cc">The container for any dialogs</param>
        /// <param name="action">The action that initiated this command</param>
        /// <exception cref="InvalidOperationException">If a specific point is not currently selected</exception>
        internal RadialUI(IControlContainer cc, IUserAction action)
            : base(cc, action)
        {
            PointFeature from = EditingController.SelectedPoint;
            if (from == null)
                throw new InvalidOperationException("You must initially select the point the sideshot radiates from.");

            m_Dialog = null;
            m_From = from;
        }
        internal InverseArcDistanceForm()
        {
            InitializeComponent();
            color1Button.BackColor = InverseColors[0];
            color2Button.BackColor = InverseColors[1];

            m_Point1 = m_Point2 = null;
            m_Cir1 = m_Cir2 = m_CommCir = null;
            m_WantShort = true;
            m_CurrentDistanceArc = null;
        }
Пример #42
0
        /// <summary>
        /// Creates a new <c>GetPointForm</c>
        /// </summary>
        /// <param name="cmd">The parent command.</param>
        /// <param name="title">The title for the window.</param>
        /// <param name="col">The color hint for the point.</param>
        /// <param name="enableBack">Should the "back" button be enabled?</param>
        internal GetPointForm(PathUI cmd, string title, Color col, bool enableBack)
        {
            InitializeComponent();

            m_Parent = cmd;
            m_Point = null;
            m_Color = col;
            m_Title = title;
            m_IsPointed = false;
            m_IsBackEnabled = enableBack;
        }
Пример #43
0
        /// <summary>
        /// Creates a new simple line segment.
        /// </summary>
        /// <param name="start">The point at the start of the new line.</param>
        /// <param name="end">The point at the end of the new line.</param>
        /// <remarks>When you add a new line segment, the two end points will be referenced both to the
        /// new line, and to the editing operation that defined the line. While this is a bit verbose,
        /// it's consistent.</remarks>
        internal void Execute(PointFeature start, PointFeature end)
        {
            // Disallow an attempt to add a null line.
            if (start.Geometry.IsCoincident(end.Geometry))
                throw new Exception("NewLineOperation.Execute - Attempt to add null line.");

            // Add the new line with default entity type.
            CadastralMapModel mapModel = this.MapModel;
            LineFeature newLine = mapModel.AddLine(start, end, mapModel.DefaultLineType, this);
            base.SetNewLine(newLine);

            // Peform standard completion steps
            Complete();
        }
Пример #44
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PathOperation"/> class
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="entryString"></param>
        internal PathOperation(PointFeature from, PointFeature to, string entryString, DistanceUnit defaultEntryUnit)
            : base()
        {
            m_From = from;
            m_To = to;
            m_EntryString = entryString;
            m_DefaultEntryUnit = defaultEntryUnit;

            Leg[] legs = PathParser.CreateLegs(m_EntryString, m_DefaultEntryUnit);
            uint lastId = PrepareLegs(this.EditSequence, legs);
            EditingController.Current.Project.SetLastItem(lastId);

            m_Legs = new List<Leg>(legs);
        }
Пример #45
0
        internal void OnSelectPoint(PointFeature point)
        {
            // Return if point is not defined.
            if (point==null)
                return;

            // Get rid of any existing offset.
            m_Offset = null;

            // Create an offset point object.
            m_Offset = new OffsetPoint(point);

            // Display the key of the offset point.
            offsetTextBox.Text = String.Format("+{0}", point.FormattedKey);

            // Disable the left-right radio buttons.
            leftRadioButton.Enabled = rightRadioButton.Enabled = false;

            // Tell the command.
            m_Cmd.SetOffset(m_Offset);
        }
Пример #46
0
 /// <summary>
 /// Ensure that a point is drawn with it's "normal" color.
 /// </summary>
 /// <param name="point">The point to set the color for.</param>
 void SetNormalColor(PointFeature point)
 {
     // Redraw in idle time
     if (point!=null)
         ErasePainting();
 }
Пример #47
0
        private void radiusTextBox_TextChanged(object sender, EventArgs e)
        {
            string str = radiusTextBox.Text.Trim();

            if (str.Length==0)
            {
                // If we already had radius info, reset it.
                SetNormalColor(m_RadiusPoint);
                m_RadiusPoint = null;
                m_RadiusDistance = null;
                OnChange();
            }
            else
            {
                // If the first character is a "+" character, it means the text was set
                // via a pointing operation. So if the first char is NOT a "+", treat it
                // as an entered radius.
                if (str[0]!='+')
                {
                    SetNormalColor(m_RadiusPoint);
                    m_RadiusPoint = null;
                    ParseRadius();
                }
            }
        }
Пример #48
0
        private void radiusTextBox_Leave(object sender, EventArgs e)
        {
            // No validation if the radius is being specified by pointing (in
            // that case, losing the focus is ok.
            if (m_RadiusPoint!=null)
            {
                OnChange();
                return;
            }

            // Return if the field is empty.
            string str = radiusTextBox.Text.Trim();
            if (str.Length==0)
            {
                OnChange();
                return;
            }

            // If the field starts with a "+" character, it must be
            // an explicitly entered point ID.
            if (str[0]=='+')
            {
                m_RadiusPoint = GetPoint(radiusTextBox);
                if (m_RadiusPoint==null)
                {
                    radiusTextBox.Focus();
                    return;
                }
            }

            // Parse the radius.
            ParseRadius();
        }
Пример #49
0
        void InitOp(NewCircleOperation op, bool isUpdate)
        {
            // Get the center point and display its ID, preceded by a "+" char.
            m_Center = op.Center;
            centerTextBox.Text = String.Format("+{0}", m_Center.FormattedKey);

            // Get the observation that was used to specify the radius.
            Observation radius = op.Radius;

            // Make a copy of the relevant info, depending on whether the
            // radius was entered, or specified as an offset point.
            if (radius is OffsetPoint)
            {
                // Radius was specified as an offset point.
                OffsetPoint offset = (radius as OffsetPoint);
                m_RadiusPoint = offset.Point;
                m_RadiusDistance = null;

                // Display the ID of the offset point, preceded with a "+" char.
                radiusTextBox.Text = String.Format("+{0}", m_RadiusPoint.FormattedKey);

                if (isUpdate)
                {
                    // If there are any incident arcs that were added using
                    // a NewLineOperation (on the same circle), disallow the
                    // ability to change the offset point.

                    // @devnote Long story. In short, if the offset point
                    // gets changed, the user could move it anywhere, so quite
                    // a sophisticated UI could be needed to re-define where
                    // the curves should go (failing that, if you let the user
                    // change things, one end of the curve moves, but not the
                    // end that met the offset point => looks bent). This is a
                    // problem even if the curves have subsequently been
                    // de-activated.

                    LineFeature line = op.Line;
                    Circle circle = line.Circle;
                    Debug.Assert(circle!=null);
                    if (circle.HasArcsAt(m_RadiusPoint))
                        radiusTextBox.Enabled = false;
                }
            }
            else
            {
                // Radius is (or should be) an entered distance.
                m_RadiusPoint = null;
                Distance dist = (radius as Distance);
                if (dist==null)
                {
                    MessageBox.Show("NewCircleForm.InitOp - Unexpected radius observation.");
                    return;
                }
                m_RadiusDistance = new Distance(dist);

                // Display the radius (will call OnChangeRadius).
                radiusTextBox.Text = m_RadiusDistance.Format();
            }

            // Ensure points are drawn ok.
            PaintAll();
        }
Пример #50
0
        private void centerTextBox_TextChanged(object sender, EventArgs e)
        {
            // If the field is now empty, ensure that the center point is undefined.
            if (centerTextBox.Text.Trim().Length==0)
            {
                SetNormalColor(m_Center);
                m_Center = null;
            }

            OnChange();
        }
Пример #51
0
        /// <summary>
        /// Appends a point to the new line. If it's the second point, the new line
        /// will be added to the map.
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        internal override bool AppendToLine(PointFeature p)
        {
            // If the start point is not defined, just remember it (ensuring
            // that the point coincides with at least one circle).
            if (StartPoint == null)
            {
                m_Circles = CadastralMapModel.Current.FindCircles(p, CircleTolerance);
                if (m_Circles.Count == 0)
                {
                    MessageBox.Show("Selected point does not coincide with any circles.");
                    return false;
                }

                return base.AppendToLine(p);
            }

            // Get the circles that pass through the selected point.
            List<Circle> circles = CadastralMapModel.Current.FindCircles(p, CircleTolerance);
            if (circles.Count == 0)
            {
                MessageBox.Show("Selected point does not coincide with any circles.");
                //SetLineCursor();
                return false;
            }

            // The point MUST coincide with one of the circles that
            // were found at the start point.
            List<Circle> comlist = Circle.GetCommonCircles(m_Circles, circles);
            if (comlist.Count == 0)
            {
                string msg = String.Empty;
                msg += ("Selected end point does not coincide with any of" + System.Environment.NewLine);
                msg += ("the circles that pass through the start point.");
                MessageBox.Show(msg);
                //SetLineCursor();
                return false;
            }

            // Could we have more than 1 to choose from?
            if (comlist.Count > 1)
            {
                string msg = String.Empty;
                msg += ("More than one circle is common to the start" + System.Environment.NewLine);
                msg += ("and the end point. Don't know what to do.");
                MessageBox.Show(msg);
                //SetLineCursor();
                return false;
            }

            // Remember the common circle (for the AddNewLine override)
            m_NewArcCircle = comlist[0];

            return base.AppendToLine(p);
        }
Пример #52
0
        /// <summary>
        /// Creates a <c>NewCircleForm</c> for a circle, based on a previously
        /// defined circle.
        /// </summary>
        /// <param name="cmd">The command creating this dialog</param>
        /// <param name="recall">The editing operation that's being recalled (null
        /// if not doing a recall)</param>
        internal NewCircleForm(CommandUI cmd, Operation recall)
        {
            InitializeComponent();

            m_Cmd = cmd;
            m_Recall = (NewCircleOperation)recall;

            m_Center = null;
            m_Radius = null;
            m_Circle = null;
            m_RadiusPoint = null;
            m_RadiusDistance = null;
            m_Focus = null;
        }
Пример #53
0
        /// <summary>
        /// Adds a new circular arc feature.
        /// </summary>
        /// <param name="end"></param>
        internal override void AddNewLine(PointFeature end)
        {
            NewArcOperation op = null;

            try
            {
                op = new NewArcOperation();
                op.Execute(StartPoint, end, m_NewArcCircle, m_IsShortArc);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace, ex.Message);
            }
        }
Пример #54
0
        internal override void Paint(PointFeature point)
        {
            // If applicable circles are defined, ensure they show
            if (m_Circles != null)
            {
                ISpatialDisplay display = ActiveDisplay;
                IDrawStyle style = new DottedStyle(Color.Magenta);
                foreach (Circle c in m_Circles)
                    c.Render(display, style);
            }

            base.Paint(point);
        }
Пример #55
0
        /// <summary>
        /// Do any command-specific drawing.
        /// </summary>
        /// <param name="point">The specific point (if any) that the parent window has drawn.
        /// Not used.</param>
        internal override void Paint(PointFeature point)
        {
            if (m_LastPosition != null)
            {
                // Draw gray text in the original position
                ISpatialDisplay display = ActiveDisplay;
                m_Text.Draw(display, Color.Gray);

                // Draw the text at the last mouse position
                IPointGeometry p = m_Text.Position;
                try
                {
                    m_Text.TextGeometry.Position = m_LastPosition;
                    m_Text.Draw(display, Color.Red);
                }

                finally
                {
                    m_Text.TextGeometry.Position = p;
                }
            }
        }
Пример #56
0
 internal void Draw(PointFeature point)
 {
     if (point==null)
         PaintAll();
     else
     {
         if (Object.ReferenceEquals(point, m_Center))
             point.Draw(ActiveDisplay, Color.Cyan);
         else if (Object.ReferenceEquals(point, m_RadiusPoint))
             point.Draw(ActiveDisplay, Color.Yellow);
     }
 }
Пример #57
0
        /// <summary>
        /// Ensures that a persistent field has been associated with a spatial feature.
        /// </summary>
        /// <param name="field">A tag associated with the item</param>
        /// <param name="feature">The feature to assign to the field (not null).</param>
        /// <returns>
        /// True if a matching field was processed. False if the field is not known to this
        /// class (may be known to another class in the type hierarchy).
        /// </returns>
        public bool ApplyFeatureRef(DataField field, Feature feature)
        {
            switch (field)
            {
                case DataField.Backsight:
                    m_Backsight = (PointFeature)feature;
                    return true;

                case DataField.From:
                    m_From = (PointFeature)feature;
                    return true;

            }

            return false;
        }
Пример #58
0
        /// <summary>
        /// Reacts to selection of a point on the map.
        /// </summary>
        /// <param name="point"></param>
        internal void OnSelectPoint(PointFeature point)
        {
            // Return if point is not defined.
            if (point==null)
                return;

            // Handle the pointing, depending on what field we were last in.
            if (m_Focus == centerTextBox)
            {
                // Draw any previously selected center point normally.
                SetNormalColor(m_Center);

                // Grab the new centre point.
                m_Center = point;

                // Draw the point in appropriate color.
                m_Center.Draw(ActiveDisplay, Color.Cyan);

                // Display its key (causes a call to OnChangeCentre).
                centerTextBox.Text = String.Format("+{0}", m_Center.FormattedKey);

                // Move focus to the radius field.
                radiusTextBox.Focus();
            }
            else if (m_Focus == radiusTextBox)
            {
                // The radius must be getting specified by pointing at an offset point.

                // Ensure that any previously selected offset point is
                // drawn in its normal colout.
                SetNormalColor(m_RadiusPoint);

                // Grab the new offset point.
                m_RadiusPoint = point;

                // Draw the point in appropriate colour.
                m_RadiusPoint.Draw(ActiveDisplay, Color.Yellow);

                // Display the point number.
                radiusTextBox.Text = String.Format("+{0}", m_RadiusPoint.FormattedKey);

                // Ensure any radius circle has been refreshed.
                OnChange();

                // Move focus to the OK button.
                okButton.Focus();
            }
        }
Пример #59
0
 /// <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);
 }
Пример #60
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NewCircleOperation"/> class
 /// </summary>
 /// <param name="center">The point at the center of the circle.</param>
 /// <param name="radius">The radius of the circle (either a <see cref="Distance"/> object,
 /// or an <see cref="OffsetPoint"/> that sits on the circumference of the circle.</param>
 internal NewCircleOperation(PointFeature center, Observation radius)
     : base()
 {
     m_Center = center;
     m_Radius = radius;
 }