public void Render(IGraphics g, WorldTransform wt)
        {
            Polygon curPoly = poly;

            if (curPoly == null)
            {
                return;
            }

            IPen pen = g.CreatePen();

            pen.Width = nom_pixel_width / wt.Scale;
            pen.Color = color;

            if (drawFilled)
            {
                g.FillPolygon(Color.FromArgb(100, color), Utility.ToPointF(curPoly));
            }

            g.DrawPolygon(pen, Utility.ToPointF(curPoly));

            if (drawCentroid)
            {
                DrawingUtility.DrawControlPoint(g, curPoly.GetCentroid(), color, null, ContentAlignment.BottomCenter, ControlPointStyle.LargeX, wt);
            }

            pen.Dispose();
        }
        public void Render(IGraphics g, WorldTransform wt)
        {
            // if we're attached to the vehicle state, update our shits
            if (attachToVehicleState)
            {
                location = Utility.ToPointF(Services.VehicleStateService.Location);
                heading  = (float)Services.VehicleStateService.Heading;
            }

            g.GoToVehicleCoordinates(location, heading);

            float penWidth = nomPixelWidth / wt.Scale;
            //if (penWidth > 0.01f) penWidth = 0.01f;
            IPen p = g.CreatePen();

            p.Width = penWidth;
            p.Color = color;

            g.DrawRectangle(p, bodyRect);

            // build the transform for the rear wheels
            // do the left wheel
            g.PushMatrix();
            g.Translate(-wheelOffset, 0);
            g.FillRectangle(Color.White, wheelRectL);
            g.DrawRectangle(p, wheelRectL);
            g.PopMatrix();

            // do the right wheel
            g.PushMatrix();
            g.Translate(wheelOffset, 0);
            g.FillRectangle(Color.White, wheelRectR);
            g.DrawRectangle(p, wheelRectR);
            g.PopMatrix();

            // do the front wheels
            // do the left wheel
            g.PushMatrix();
            g.Translate(-wheelOffset, wheelbase);
            g.FillRectangle(Color.White, wheelRectL);
            g.DrawRectangle(p, wheelRectL);
            g.PopMatrix();

            // do the right wheel
            g.PushMatrix();
            g.Translate(wheelOffset, wheelbase);
            g.FillRectangle(Color.White, wheelRectR);
            g.DrawRectangle(p, wheelRectR);
            g.PopMatrix();

            // draw the forward arrow
            g.DrawLine(p, new PointF(bodyRect.Left + 0.5f, bodyRect.Bottom - bodyRect.Width / 2), new PointF(bodyRect.Left + bodyRect.Width / 2, bodyRect.Bottom - .5f));
            g.DrawLine(p, new PointF(bodyRect.Right - 0.5f, bodyRect.Bottom - bodyRect.Width / 2), new PointF(bodyRect.Right - bodyRect.Width / 2, bodyRect.Bottom - .5f));

            g.DrawCross(p, new PointF(0, 0), 8 / wt.Scale);

            g.ComeBackFromVehicleCoordinates();

            p.Dispose();
        }
Exemple #3
0
        public void Render(IGraphics g, WorldTransform wt)
        {
            LinePath path = line;

            if (path == null)
            {
                return;
            }

            PointF[] pts = Utility.ToPointF(path);
            IPen     p   = g.CreatePen();

            p.Color = color;
            p.Width = nom_pixel_width / wt.Scale;
            g.DrawLines(p, pts);
            p.Dispose();

            if (labelPoints)
            {
                for (int i = 0; i < path.Count; i++)
                {
                    DrawingUtility.DrawControlPoint(g, path[i], Color.Black, i.ToString(), ContentAlignment.MiddleRight, ControlPointStyle.SmallX, wt);
                }
            }
        }
Exemple #4
0
 public void Release()
 {
     if (_pen != null)
     {
         _pen.Dispose();
         _pen = null;
     }
 }
Exemple #5
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         fCtlPen.Dispose();
         fCtlBrush.Dispose();
     }
     base.Dispose(disposing);
 }
Exemple #6
0
        public void Render(IGraphics g, WorldTransform wt)
        {
            ArcVotingResults results = this.results;

            if (results == null)
            {
                return;
            }

            // get the current vehicle position/heading
            float  vehicleHeading = (float)Services.VehicleStateService.Heading;
            PointF vehiclePos     = Utility.ToPointF(Services.VehicleStateService.Location);

            g.GoToVehicleCoordinates(vehiclePos, vehicleHeading + (float)Math.PI / 2.0f);

            IPen p = g.CreatePen();

            p.Color = color;
            p.Width = nomPixelWidth / wt.Scale;

            foreach (ArcResults result in results.arcResults)
            {
                // generate the arc
                if (Math.Abs(result.curvature) < 1e-4)
                {
                    g.DrawLine(p, new PointF(0, 0), new PointF(dist, 0));
                }
                else
                {
                    double curvature   = result.curvature;
                    bool   leftTurn    = curvature > 0;
                    double radius      = Math.Abs(1 / curvature);
                    double frontRadius = Math.Sqrt(TahoeParams.FL * TahoeParams.FL + radius * radius);

                    CircleSegment rearSegment;

                    if (leftTurn)
                    {
                        Coordinates center = new Coordinates(0, radius);
                        rearSegment = new CircleSegment(radius, center, Coordinates.Zero, dist, true);
                    }
                    else
                    {
                        Coordinates center = new Coordinates(0, -radius);
                        rearSegment = new CircleSegment(radius, center, Coordinates.Zero, dist, false);
                    }

                    PointF[] points = Utility.ToPointF(rearSegment.ToPoints(10));
                    g.DrawLines(p, points);
                }
            }

            g.ComeBackFromVehicleCoordinates();

            p.Dispose();
        }
Exemple #7
0
        public void Render(IGraphics g, WorldTransform wt)
        {
            IPen p = g.CreatePen();

            p.Color = color;
            p.Width = nomPixelWidth / wt.Scale;

            PointF[] points = Utility.ToPointF(segment.ToPoints(30));
            g.DrawLines(p, points);

            p.Dispose();
        }
Exemple #8
0
        public void Release()
        {
            if (_brush != null)
            {
                _brush.Dispose();
            }

            _brush = null;
            if (_pen != null)
            {
                _pen.Dispose();
            }

            _pen = null;
        }
Exemple #9
0
        public void DisposeBrushes()
        {
            for (int i = 0; i < fOptions.BrushColor.Length; i++)
            {
                if (fCircleBrushes[i] != null)
                {
                    fCircleBrushes[i].Dispose();
                }
                if (fDarkBrushes[i] != null)
                {
                    fDarkBrushes[i].Dispose();
                }
            }

            if (fPen != null)
            {
                fPen.Dispose();
            }
        }
        private void DrawZoomBox(IGraphics g, WorldTransform transform, Coordinates start, Coordinates end)
        {
            float x, y;
            float width, height;

            if (start.X < end.X)
            {
                x     = (float)start.X;
                width = (float)(end.X - start.X);
            }
            else
            {
                x     = (float)end.X;
                width = (float)(start.X - end.X);
            }

            if (start.Y < end.Y)
            {
                y      = (float)start.Y;
                height = (float)(end.Y - start.Y);
            }
            else
            {
                y      = (float)end.Y;
                height = (float)(start.Y - end.Y);
            }

            // create the rectangle
            RectangleF rect = new RectangleF(x, y, width, height);

            // draw the transparent background
            g.FillRectangle(Color.FromArgb(50, Color.Purple), rect);

            IPen pen = g.CreatePen();

            pen.Width = 1.0f / transform.Scale;
            pen.Color = Color.Purple;

            g.DrawRectangle(pen, rect);

            pen.Dispose();
        }
        public void Render(IGraphics g, WorldTransform wt)
        {
            Polygon[] polys = this.polys;
            if (polys == null)
            {
                return;
            }

            IPen p = g.CreatePen();

            p.Width = nom_pixel_width / wt.Scale;
            p.Color = color;

            foreach (Polygon poly in polys)
            {
                g.DrawPolygon(p, Utility.ToPointF(poly));
            }

            p.Dispose();
        }