Пример #1
0
        bool InitOp(RadialOperation pop)
        {
            if (pop==null)
                return false;

            // Get the point the sideshot was observed from (unless
            // it is already defined).
            if (m_From==null)
                m_From = pop.From;

            // Was a backsight specified?
            Direction dir = pop.Direction;
            if (dir is AngleDirection)
            {
                AngleDirection angle = (AngleDirection)dir;
                m_Backsight = angle.Backsight;
                m_Radians = angle.ObservationInRadians;
                if (m_Radians < 0.0)
                {
                    m_Radians = Math.Abs(m_Radians);
                    m_IsClockwise = false;
                }
                else
                    m_IsClockwise = true;

                // Is it a deflection?
                m_IsDeflection = (dir is DeflectionDirection);
            }

            // Was direction specified using 2 points (not possible
            // if we've already picked up a backsight).
            if (m_Backsight==null)
            {
                ParallelDirection par = (dir as ParallelDirection);
                if (par!=null)
                {
                    m_Par1 = par.Start;
                    m_Par2 = par.End;
                }
            }
            else
            {
                // Does the backsight point correspond to the centre of a
                // circle that passes through the from-point?

                double radius = Geom.Distance(m_Backsight, m_From);
                if (m_Backsight.GetCircle(radius)!=null)
                    m_WantCentre = true;
            }

            // If we don't have a backsight or a parallel point, it must be a bearing.
            if (!(m_Backsight!=null || m_Par1!=null))
                m_Radians = dir.Bearing.Radians;

            // Did the direction have an offset? If so, make a transient
            // copy (specifying m_Length since it's transient).
            Offset offset = dir.Offset;
            if (offset!=null)
                m_Offset = offset;
                //m_Offset = offset.MakeNewCopy(m_Length);

            // The length was either entered explicitly, or via an offset point.
            Observation length = pop.Length;
            Distance dist = (length as Distance);

            if (dist!=null)
            {
                m_Length = new Distance(dist);
            }
            else
            {
                // It SHOULD be an offset point.
                OffsetPoint offsetPoint = (OffsetPoint)length;
                if (offsetPoint!=null)
                    m_LengthOffset = new OffsetPoint(offsetPoint);
            }

            // Remember whether a line was added.
            if (pop.Line!=null)
                m_WantLine = true;

            return true;
        }
Пример #2
0
 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;
 }
Пример #3
0
 internal RadialControl(RadialUI cmd, PointFeature from)
 {
     InitializeComponent();
     Zero();
     m_Cmd = cmd;
     m_From = from;
     m_Recall = (RadialOperation)cmd.Recall;
     m_PointId = new IdHandle();
     InitOp(m_Recall);
 }
Пример #4
0
        /// <summary>
        /// Reacts to selection of the OK button in the dialog.
        /// </summary>
        /// <param name="wnd">The dialog window. If this matches the dialog that
        /// this command knows about, the command will be executed (and, on success,
        /// the dialog will be destroyed). If it's some other window, it must
        /// be a sub-dialog created by our guy, so let it handle the request.</param>
        /// <returns></returns>
        internal override bool DialFinish(Control wnd)
        {
            if (m_Dialog==null)
            {
                MessageBox.Show("RadialUI.DialFinish - No dialog!");
                return false;
            }

            // Handle any sub-dialog request.
            if (m_Dialog != wnd )
                return m_Dialog.DialFinish(wnd);

            // If we are doing an update, remember the changes
            UpdateUI up = this.Update;

            if (up!=null)
            {
                RadialOperation pop = (up.GetOp() as RadialOperation);
                if (pop==null)
                {
                    MessageBox.Show("RadialUI.DialFinish - Unexpected edit type.");
                    return false;
                }

                // Get info from the dialog.
                Direction dir = m_Dialog.Direction;
                Observation len = m_Dialog.Length;

                // The direction and length must both be defined.
                if (dir==null || len==null)
                {
                    MessageBox.Show("Missing parameters for sideshot update.");
                    return false;
                }

                // Remember the changes as part of the UI object (the original edit remains
                // unchanged for now)
                UpdateItemCollection changes = pop.GetUpdateItems(dir, len);
                if (!up.AddUpdate(pop, changes))
                    return false;
            }
            else
            {
                // Get info from the dialog.
                Direction dir = m_Dialog.Direction;
                Observation len = m_Dialog.Length;
                IdHandle idh = m_Dialog.PointId;

                IEntity lineEnt = null;
                if (m_Dialog.WantLine)
                {
                    lineEnt = CadastralMapModel.Current.DefaultLineType;
                    if (lineEnt==null)
                        throw new InvalidOperationException("No default entity type for lines");
                }

                // The direction, length, and point entity type must all be defined.
                if (dir==null || len==null || idh.Entity==null)
                {
                    MessageBox.Show("Missing parameters for sideshot creation.");
                    return false;
                }

                RadialOperation pop = null;

                try
                {
                    pop = new RadialOperation(dir, len);
                    pop.Execute(idh, lineEnt);
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.StackTrace, ex.Message);
                }
            }

            // Get the base class to finish up.
            return FinishCommand();
        }