Пример #1
0
        private void angleButton_Click(object sender, EventArgs e)
        {
            StraightLeg leg = (CurrentFace.Leg as StraightLeg);

            if (leg == null)
            {
                return;
            }

            using (AngleForm dial = new AngleForm(leg))
            {
                if (dial.ShowDialog() == DialogResult.OK)
                {
                    if (dial.IsDeflection)
                    {
                        leg.SetDeflection(dial.SignedAngle);
                    }
                    else
                    {
                        leg.StartAngle = dial.SignedAngle;
                    }

                    m_Edits.SetStartAngle(m_CurFaceIndex, dial.SignedAngle, dial.IsDeflection);
                    Rework();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Constructor for the angle at the start of a straight leg 
        /// (used when editing a connection path).
        /// </summary>
        /// <param name="leg">The leg that's being edited</param>
        internal AngleForm(StraightLeg leg)
        {
            InitializeComponent();

            m_Radians = leg.StartAngle;
            m_IsClockwise = (m_Radians>=0.0);
            m_Radians = Math.Abs(m_Radians);
            m_IsDefined = true;
            m_IsDeflection = leg.IsDeflection;
        }
Пример #3
0
        /// <summary>
        /// Constructor for the angle at the start of a straight leg
        /// (used when editing a connection path).
        /// </summary>
        /// <param name="leg">The leg that's being edited</param>
        internal AngleForm(StraightLeg leg)
        {
            InitializeComponent();

            m_Radians      = leg.StartAngle;
            m_IsClockwise  = (m_Radians >= 0.0);
            m_Radians      = Math.Abs(m_Radians);
            m_IsDefined    = true;
            m_IsDeflection = leg.IsDeflection;
        }
Пример #4
0
        /// <summary>
        /// Returns the definition of the straight leg which created a specific feature.
        /// </summary>
        /// <param name="prevStraightToo">Does the leg preceding the one found need to be
        /// straight as well? If you say <c>true</c>, a previous leg <b>must</b> exist.</param>
        /// <param name="feature">The feature to find.</param>
        /// <returns>The leg that created the feature (or null if the leg could
        /// not be found).</returns>
        StraightLeg GetStraightLeg(bool prevStraightToo, Feature feature)
        {
            // Find the leg that created the specified feature.
            int index = -1;

            for (int i = 0; i < m_Legs.Count && index < 0; i++)
            {
                if (m_Legs[i].IsCreatorOf(feature))
                {
                    index = i;
                }
            }

            // Return if it wasn't found.
            if (index < 0)
            {
                return(null);
            }

            // If the preceding leg has to be straight, getting the
            // very first leg is no good.
            if (prevStraightToo && index == 0)
            {
                return(null);
            }

            // The leg HAS to be straight.
            StraightLeg straight = (m_Legs[index] as StraightLeg);

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

            // Check if the preceding leg has to be straight as well.
            if (prevStraightToo)
            {
                StraightLeg prev = (m_Legs[index - 1] as StraightLeg);
                if (prev == null)
                {
                    return(null);
                }
            }

            return(straight);
        }
Пример #5
0
        private void breakButton_Click(object sender, EventArgs e)
        {
            LegFace     face = this.CurrentFace;
            StraightLeg leg  = (face.Leg as StraightLeg);

            if (leg == null)
            {
                return;
            }

            // You can't break a staggered leg (this should have already been trapped by disabling the button).
            if (leg.IsStaggered)
            {
                MessageBox.Show("You cannot break a staggered leg.");
                return;
            }

            // Get the selected distance
            Distance dist = GetSel();

            if (dist == null)
            {
                MessageBox.Show("You must first select a distance from the list.");
                return;
            }

            // Are we breaking before or after the currently selected distance?
            bool isBefore = brkBeforeRadioButton.Checked;

            // You can't break at the very beginning or end of the leg.
            int index = leg.PrimaryFace.GetIndex(dist);

            if (isBefore && index == 0)
            {
                MessageBox.Show("You can't break at the very beginning of the leg.");
                return;
            }

            if (!isBefore && (index + 1) == face.Count)
            {
                MessageBox.Show("You can't break at the very end of the leg.");
                return;
            }

            // Break the leg.
            if (!isBefore)
            {
                index++;
            }

            m_Edits.BreakLeg(m_CurFaceIndex, index);

            StraightLeg newLeg = leg.Break(index);

            if (newLeg == null)
            {
                return;
            }

            // Make the new leg the current one, and select the very first distance.
            int faceIndex = m_Faces.IndexOf(face);

            Debug.Assert(faceIndex >= 0);
            m_Faces.Insert(faceIndex + 1, newLeg.PrimaryFace);
            SetCurrentFace(faceIndex + 1);
            Refresh(0);
        }
Пример #6
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 rotation & scale factor to apply.
            PathInfo pd = new PathInfo(this);

            // Go through each leg, creating the geometry for each span...
            // (the following is based on the logic of PathInfo.Render)

            // Initialize position to the start of the path.
            IPosition gotend = m_From;

            // Initial bearing is whatever the desired rotation is.
            double bearing = pd.RotationInRadians;
            double sfac    = pd.ScaleFactor;

            for (int i = 0; i < m_Legs.Count; i++)
            {
                Leg leg = m_Legs[i];

                // Include any angle specified at the start of the leg
                StraightLeg sLeg = (leg as StraightLeg);
                if (sLeg != null)
                {
                    bearing = sLeg.AddStartAngle(bearing);
                }

                // Determine exit bearing for circular leg (do it now, in case an extra leg complicates matters below)
                double      exitBearing = bearing;
                CircularLeg cLeg        = (leg as CircularLeg);
                if (cLeg != null)
                {
                    IPosition center, ec;
                    double    bear2bc;
                    cLeg.GetPositions(gotend, bearing, sfac, out center, out bear2bc, out ec, out exitBearing);

                    // The circle should have been created already, but with an undefined radius
                    Circle circle = cLeg.Circle;
                    Debug.Assert(circle != null);
                    circle.Radius = cLeg.RadiusInMeters * sfac;
                    circle.CenterPoint.ApplyPointGeometry(ctx, PointGeometry.Create(center));
                }

                // Obtain geometry for each span and assign to attached features
                SpanInfo[]      spans    = leg.PrimaryFace.Spans;
                ILineGeometry[] sections = leg.GetSpanSections(gotend, bearing, sfac, spans);
                AttachGeometry(ctx, spans, sections);

                // Note the position at the end of the leg
                IPointGeometry legEnd = sections[sections.Length - 1].End;

                // If we're dealing with the first face of a staggered leg, process the second face
                if (leg.AlternateFace != null)
                {
                    // If this is the very last leg, make sure we use the path end point (there could
                    // conceivably be some roundoff).
                    if (i == m_Legs.Count - 1)
                    {
                        legEnd = m_To.PointGeometry;
                    }

                    spans    = leg.AlternateFace.Spans;
                    sections = leg.GetSpanSections(gotend, legEnd, spans);
                    AttachGeometry(ctx, spans, sections);
                }

                // Get to the end of the leg
                gotend  = legEnd;
                bearing = exitBearing;
            }
        }