예제 #1
0
        public override void DrawRegionRepresentation(Graphics gc, Render.RenderParameter r, Render.IDrawVisitor drawMethods, PointD mousePosition)
        {
            if (m_Param.Path.PointCount > 0)
            {
                GraphicsPath fill = new GraphicsPath();
                RectangleF rect = m_Param.Path.GetBounds();
                PointD refPt = (PointD)rect.Location + ((PointD)rect.Size.ToPointF()) / 2;
                // this will draw beyond the shape's location
                for (double i = -rect.Height; i < rect.Height; i++)
                {
                    PointD orth = PointD.Orthogonal(m_Param.V);
                    PointD pt1 = refPt + orth * i * drawMethods.Spacing(m_Param.C);
                    PointD pt2 = pt1 + m_Param.V * rect.Width * rect.Height;
                    PointD pt3 = pt1 - m_Param.V * rect.Width * rect.Height;

                    PointD pt4 = refPt + m_Param.V * i * drawMethods.Spacing(m_Param.C);
                    PointD pt5 = pt4 + orth * rect.Width * rect.Height;
                    PointD pt6 = pt4 - orth * rect.Width * rect.Height;

                    fill.StartFigure();
                    fill.AddLine((Point)pt2, (Point)pt3);

                    fill.StartFigure();
                    fill.AddLine((Point)pt5, (Point)pt6);

                }

                GraphicsContainer c = gc.BeginContainer();
                gc.SetClip( (Tools.Model.VectorPath) m_Param.Path);
                gc.DrawPath(r.RegionGuides, fill);
                gc.EndContainer(c);

            }
        }
예제 #2
0
        /*
        gc.DrawLine(Pens.Green, new Point(100, 100), new Point(300, 200));
        gc.DrawEllipse(Pens.Green, (float)mappedToLine.X, (float)mappedToLine.Y, 4f, 4f);
        gc.DrawLine(Pens.Green, 100f, 100f, 100f + (float)normalComponent.X, 100f + (float)normalComponent.Y);
         */
        protected override void SecondCache(Render.IDrawVisitor drawMethods)
        {
            if (m_Param.Path.PointCount == 0)
                return;

            PointF[] array = ((Tools.Model.VectorPath)m_Param.Path).InternalPath.PathPoints;

            // calculate number of lines to show for feedback
            int spacing = (int)drawMethods.Spacing(m_Param.C);
            int numLines = (int)m_Param.PathThickness / spacing;

            // build a number of trace lines
            m_traceLines = new List<PointF>[numLines];
            for (int j = 0; j < numLines; j++)
                m_traceLines[j] = new List<PointF>(array.Length);

            // render all the points
            for (int i = 1; i < array.Length; i += 2)
            {
                PointD tangent = new PointD(array[i].X - array[i - 1].X, array[i].Y - array[i - 1].Y);
                tangent = tangent / tangent.Magnitude();
                PointD normalVector = PointD.Orthogonal(tangent);

                PointD pointOnLine = new PointD((array[i].X + array[i - 1].X) / 2.0, (array[i].Y + array[i - 1].Y) / 2.0);

                for (int k = 0; k < numLines; k++)
                {
                    PointD testPt = pointOnLine + normalVector * spacing * (k - numLines / 2);
                    m_traceLines[k].Add((PointF)testPt);
                }

                //PointD testNormal1 = (testPt1 - pointOnLine);
                //testNormal1 = testNormal1 / testNormal1.Magnitude();

                //PointD testNormal2 = (testPt2 - pointOnLine);
                //testNormal2 = testNormal2 / testNormal2.Magnitude();

                //PointD scaledVector1 = testNormal1 * (GetScalar() * 7 * m_Param.C / Math.Pow((m_Param.PtRadius / 2.0) + 10, 0.5));
                //PointD scaledVector2 = testNormal2 * (GetScalar() * 7 * m_Param.C / Math.Pow((m_Param.PtRadius / 2.0) + 10, 0.5));

                //drawMethods.DrawArrow(gc, r, testPt1, scaledVector1 * Render.DrawHelper.SPEED_AMPLIFIER);
                //drawMethods.DrawArrow(gc, r, testPt2, scaledVector2 * Render.DrawHelper.SPEED_AMPLIFIER);
            }
        }