Example #1
0
        private void CalculateCurvature()
        {
            Curvature = 0;

            if (ControlPoints.Length == 2)
            {
                TargetPoint = GetTValuePointForLinear();
            }
            else if (ControlPoints.Length == 3)
            {
                IWhiskerPoint cWhiskerPoint0 = Whisker.WhiskerPoints[0];
                IWhiskerPoint cWhiskerPoint1 = Whisker.WhiskerPoints[1];
                IWhiskerPoint cWhiskerPoint2 = Whisker.WhiskerPoints[2];

                Point[] points = new Point[3];
                points[0] = new Point(cWhiskerPoint0.XRatio * VideoWidth, cWhiskerPoint0.YRatio * VideoHeight);
                points[1] = new Point(cWhiskerPoint1.XRatio * VideoWidth, cWhiskerPoint1.YRatio * VideoHeight);
                points[2] = new Point(cWhiskerPoint2.XRatio * VideoWidth, cWhiskerPoint2.YRatio * VideoHeight);

                Curvature = DrawingUtility.GetQuadraticBezierCurvature(points, TValue);

                TargetPoint = GetTValuePointForQuadratic();
            }
            else
            {
                IWhiskerPoint cWhiskerPoint0 = Whisker.WhiskerPoints[0];
                IWhiskerPoint cWhiskerPoint1 = Whisker.WhiskerPoints[1];
                IWhiskerPoint cWhiskerPoint2 = Whisker.WhiskerPoints[2];
                IWhiskerPoint cWhiskerPoint3 = Whisker.WhiskerPoints[3];

                Point[] points = new Point[4];
                points[0] = new Point(cWhiskerPoint0.XRatio * VideoWidth, cWhiskerPoint0.YRatio * VideoHeight);
                points[1] = new Point(cWhiskerPoint1.XRatio * VideoWidth, cWhiskerPoint1.YRatio * VideoHeight);
                points[2] = new Point(cWhiskerPoint2.XRatio * VideoWidth, cWhiskerPoint2.YRatio * VideoHeight);
                points[3] = new Point(cWhiskerPoint3.XRatio * VideoWidth, cWhiskerPoint3.YRatio * VideoHeight);

                Curvature   = DrawingUtility.GetCubicBezierCurvature(points, TValue);
                TargetPoint = GetTValuePointForCubic();
            }
        }
        public void Render(System.Drawing.Graphics g, WorldTransform t)
        {
            Color c;

            if (this.selected == SelectionType.NotSelected)
            {
                c = DrawingUtility.ColorArbiterUserWaypoint;
            }
            else
            {
                c = DrawingUtility.ColorArbiterUserWaypointSelected;
            }

            if (DrawingUtility.DisplayArbiterWaypointId)
            {
                DrawingUtility.DrawControlPoint(this.position, c, this.WaypointId.ToString(), ContentAlignment.BottomCenter, ControlPointStyle.SmallCircle, g, t);
            }
            else
            {
                DrawingUtility.DrawControlPoint(this.position, c, null, ContentAlignment.BottomCenter, ControlPointStyle.SmallCircle, g, t);
            }
        }
Example #3
0
        private void CTimPreviewTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            cTimPreviewTimer.Stop();
            Invoke(new MethodInvoker(delegate() {
                if (!String.IsNullOrEmpty(txtInput.Text))
                {
                    Int32 pIntCharIndex = txtInput.GetCharIndexFromPosition(cPntMousePos);
                    Int32 pIntLine      = txtInput.GetLineFromCharIndex(pIntCharIndex);
                    Int32 pIntStart     = txtInput.GetFirstCharIndexFromLine(pIntLine);
                    Int32 pIntEnd       = txtInput.Text.IndexOf("\r", pIntStart);
                    String pStrLine     = txtInput.Text.Substring(pIntStart, pIntEnd - pIntStart);

                    Int32 pIntStartKey = pStrLine.IndexOf('(');
                    Int32 pIntEndKey   = pStrLine.IndexOf(')');
                    if (pIntStartKey > -1 && pIntEndKey > pIntStartKey)
                    {
                        Int32 pInLength = (pIntEndKey - pIntStartKey);
                        String pStrKey  = pStrLine.Substring(pIntStartKey + 1, pInLength - 1);

                        if (cDlgPreviewPopup != null)
                        {
                            cDlgPreviewPopup.Dispose();
                            cDlgPreviewPopup = null;
                        }
                        cDlgPreviewPopup               = new dlgImaePreviewPopup();
                        cDlgPreviewPopup.Opacity       = 0.75f;
                        cDlgPreviewPopup.TopMost       = true;
                        cDlgPreviewPopup.StartPosition = FormStartPosition.Manual;
                        cDlgPreviewPopup.Location      = txtInput.PointToScreen(cPntMousePos);
                        Image pImgThumb = DrawingUtility.LowQualityScaledThumbnail(cKPtProject.Images.Images[pStrKey].Image,
                                                                                   200,
                                                                                   200);
                        cDlgPreviewPopup.Image = pImgThumb;
                        cDlgPreviewPopup.Show();
                        cDlgPreviewPopup.Size = new Size(pImgThumb.Width, pImgThumb.Height);
                    }
                }
            }));
        }
        public void Render(System.Drawing.Graphics g, WorldTransform t)
        {
            if (DrawingUtility.DrawArbiterZoneMap)
            {
                foreach (Polygon p in this.StayOutAreas)
                {
                    DrawingUtility.DrawControlPolygon(p, Color.SteelBlue, System.Drawing.Drawing2D.DashStyle.Solid, g, t);
                    foreach (Coordinates c in p)
                    {
                        DrawingUtility.DrawControlPoint(c, Color.SteelBlue, null, ContentAlignment.MiddleCenter, ControlPointStyle.SmallCircle, g, t);
                    }
                }

                foreach (INavigableNode nn in this.NavigationNodes)
                {
                    DrawingUtility.DrawControlPoint(nn.Position, Color.DarkOrange, null, ContentAlignment.MiddleCenter, ControlPointStyle.SmallCircle, g, t);
                }

                foreach (NavigableEdge ne in this.NavigableEdges)
                {
                    DrawingUtility.DrawColoredArrowControlLine(Color.DarkBlue, System.Drawing.Drawing2D.DashStyle.Solid, ne.Start.Position, ne.End.Position, g, t);
                }
            }
        }
Example #5
0
        public void Render(System.Drawing.Graphics g, WorldTransform t)
        {
            if (this.trackedCluster.targetClass == SceneEstimatorTargetClass.TARGET_CLASS_CARLIKE)
            {
                bool clusterStopped = this.trackedCluster.isStopped;
                bool occluded       = ((this.trackedCluster.statusFlag == SceneEstimatorTargetStatusFlag.TARGET_STATE_OCCLUDED_FULL && clusterStopped) ||
                                       (this.trackedCluster.statusFlag == SceneEstimatorTargetStatusFlag.TARGET_STATE_OCCLUDED_PART && clusterStopped));

                Color c = this.trackedCluster.statusFlag == SceneEstimatorTargetStatusFlag.TARGET_STATE_ACTIVE ?
                          DrawingUtility.ColorSimTrafficCar :
                          DrawingUtility.ColorSimDeletedCar;

                if (occluded)
                {
                    c = Color.Chocolate;
                }
                else if ((this.trackedCluster.statusFlag == SceneEstimatorTargetStatusFlag.TARGET_STATE_OCCLUDED_FULL && !clusterStopped) ||
                         (this.trackedCluster.statusFlag == SceneEstimatorTargetStatusFlag.TARGET_STATE_OCCLUDED_PART && !clusterStopped))
                {
                    occluded = true;
                    c        = Color.DarkOrange;
                }

                if (this.trackedCluster.statusFlag == SceneEstimatorTargetStatusFlag.TARGET_STATE_ACTIVE &&
                    this.trackedCluster.isStopped && this.trackedCluster.speedValid)
                {
                    c = Color.Red;
                }
                else if (this.trackedCluster.statusFlag == SceneEstimatorTargetStatusFlag.TARGET_STATE_ACTIVE &&
                         this.trackedCluster.isStopped && !this.trackedCluster.speedValid)
                {
                    c = Color.SkyBlue;
                }

                bool draw = this.trackedCluster.statusFlag == SceneEstimatorTargetStatusFlag.TARGET_STATE_ACTIVE || occluded ?
                            DrawingUtility.DrawSimCars :
                            DrawingUtility.DrawSimCars && DrawingUtility.DrawSimCarDeleted;

                if (draw)
                {
                    Coordinates heading      = (new Coordinates(1, 0)).Rotate(this.trackedCluster.absoluteHeading).Normalize(3.0);
                    Coordinates headingCoord = this.trackedCluster.closestPoint + heading;

                    if (trackedCluster.headingValid)
                    {
                        DrawingUtility.DrawColoredControlLine(Color.Blue, DashStyle.Solid, this.trackedCluster.closestPoint, headingCoord, g, t);
                    }

                    if (DrawingUtility.DrawSimCarId)
                    {
                        DrawingUtility.DrawControlPoint(
                            this.trackedCluster.closestPoint,
                            c,
                            this.trackedCluster.id.ToString(),
                            ContentAlignment.TopLeft,
                            ControlPointStyle.LargeBox,
                            g, t);

                        DrawingUtility.DrawControlPoint(
                            this.trackedCluster.closestPoint,
                            c,
                            this.trackedCluster.speed.ToString("f1"),
                            ContentAlignment.BottomLeft,
                            ControlPointStyle.LargeBox,
                            g, t);

                        DrawingUtility.DrawControlPoint(
                            this.trackedCluster.closestPoint,
                            c,
                            this.PartitionIdString(),
                            ContentAlignment.BottomRight,
                            ControlPointStyle.LargeBox,
                            g, t);
                    }
                    else
                    {
                        DrawingUtility.DrawControlPoint(
                            this.trackedCluster.closestPoint,
                            c,
                            null,
                            ContentAlignment.MiddleCenter,
                            ControlPointStyle.LargeBox,
                            g, t);
                    }
                }
            }
        }
 public void Render(System.Drawing.Graphics g, WorldTransform t)
 {
     DrawingUtility.DrawColoredControlLine(DrawingUtility.ColorArbiterParkingSpot, System.Drawing.Drawing2D.DashStyle.Solid,
                                           this.NormalWaypoint.Position, this.Checkpoint.Position, g, t);
 }
Example #7
0
        public void Render(System.Drawing.Graphics g, WorldTransform t)
        {
            // width of drawing
            float penWidth = nomPixelWidth / t.Scale;

            // body rectangle
            RectangleF bodyRect = new RectangleF((float)(-this.Width / 2), -rearOffset, (float)Width, (float)Length);

            // body transformation matrix
            Matrix bodyTrans = new Matrix();

            bodyTrans.Rotate((float)(this.Heading.ToDegrees() - 90));
            bodyTrans.Translate((float)Position.X, (float)Position.Y, MatrixOrder.Append);

            // save original world transformation matrix
            Matrix origTrans = g.Transform.Clone();

            bodyTrans.Multiply(g.Transform, MatrixOrder.Append);

            // set the new transform
            g.Transform = bodyTrans;

            // make a new pen and draw wheels
            using (Pen p = new Pen(color, penWidth))
            {
                DrawRectangle(g, p, bodyRect);

                // build the transform for the rear wheels
                // do the left wheel
                Matrix wheelTransform = bodyTrans.Clone();
                wheelTransform.Translate(-wheelOffset, 0, MatrixOrder.Prepend);
                g.Transform = wheelTransform;
                g.FillRectangle(Brushes.White, wheelRectL);
                DrawRectangle(g, p, wheelRectL);

                // do the right wheel
                wheelTransform = bodyTrans.Clone();
                wheelTransform.Translate(wheelOffset, 0, MatrixOrder.Prepend);
                g.Transform = wheelTransform;
                g.FillRectangle(Brushes.White, wheelRectR);
                DrawRectangle(g, p, wheelRectR);

                // do the front wheels
                // do the left wheel
                wheelTransform = bodyTrans.Clone();
                wheelTransform.Translate(-wheelOffset, wheelbase, MatrixOrder.Prepend);
                wheelTransform.Rotate(steeringAngle * 180 / (float)Math.PI, MatrixOrder.Prepend);
                g.Transform = wheelTransform;
                g.FillRectangle(Brushes.White, wheelRectL);
                DrawRectangle(g, p, wheelRectL);

                // do the right wheel
                wheelTransform = bodyTrans.Clone();
                wheelTransform.Translate(wheelOffset, wheelbase, MatrixOrder.Prepend);
                wheelTransform.Rotate(steeringAngle * 180 / (float)Math.PI, MatrixOrder.Prepend);
                g.Transform = wheelTransform;
                g.FillRectangle(Brushes.White, wheelRectR);
                DrawRectangle(g, p, wheelRectR);
            }

            // return to normal transformation
            g.Transform = origTrans;

            // draw car center point
            DrawingUtility.DrawControlPoint(this.Position, this.color, null, ContentAlignment.MiddleCenter, ControlPointStyle.LargeX, g, t);

            // check if should draw id
            if (DrawingUtility.DrawSimCarId)
            {
                // get length
                double idOffset = this.Length / 2;

                if (this.RearAxleType == RearAxleType.Center)
                {
                    idOffset = this.Length / 3;
                }

                // get label position
                Coordinates labelPosition = this.Position + this.Heading.Normalize(idOffset);

                // draw label
                DrawingUtility.DrawControlLabel(labelPosition, this.color, this.Id, ContentAlignment.MiddleCenter, ControlPointStyle.None, g, t);
            }
        }
        public void NavigationHitTest(Coordinates c, out INavigableNode node, out NavigableEdge edge)
        {
            if (this.zt.current != null)
            {
                // Determine size of bounding box
                float scaled_offset = 1 / this.rd.WorldTransform.Scale;

                // invert the scale
                float scaled_size = DrawingUtility.cp_large_size;

                // assume that the world transform is currently applied correctly to the graphics
                RectangleF rect = new RectangleF((float)c.X - scaled_size / 2, (float)c.Y - scaled_size / 2, scaled_size, scaled_size);

                foreach (ArbiterParkingSpotWaypoint apsw in this.zt.current.ParkingSpotWaypoints.Values)
                {
                    if (apsw.Position.DistanceTo(c) < 1.0)
                    {
                        node = apsw;
                        edge = null;
                        return;
                    }
                }

                foreach (ArbiterPerimeterWaypoint apw in this.zt.current.Perimeter.PerimeterPoints.Values)
                {
                    if ((apw.IsExit || apw.IsEntry) && rect.Contains(DrawingUtility.ToPointF(apw.Position)) &&
                        (this.PreviousNode == null || !this.PreviousNode.Equals(apw)) &&
                        apw.Position.DistanceTo(c) < 1.0)
                    {
                        node = apw;
                        edge = null;
                        return;
                    }
                }

                foreach (INavigableNode inn in this.zt.current.NavigationNodes)
                {
                    if (rect.Contains(DrawingUtility.ToPointF(inn.Position)) &&
                        (this.PreviousNode == null || !this.PreviousNode.Equals(inn)) &&
                        inn.Position.DistanceTo(c) < 1.0)
                    {
                        node = inn;
                        edge = null;
                        return;
                    }
                }

                NavigableEdge closest  = null;
                double        distance = double.MaxValue;
                foreach (NavigableEdge ne in this.zt.current.NavigableEdges)
                {
                    LinePath lp   = new LinePath(new Coordinates[] { ne.Start.Position, ne.End.Position });
                    double   dist = lp.GetClosestPoint(c).Location.DistanceTo(c);
                    if (dist < rect.Width && (dist < distance || closest == null) && dist < 1.0)
                    {
                        closest  = ne;
                        distance = dist;
                    }
                }

                if (closest != null)
                {
                    node = null;
                    edge = closest;
                    return;
                }
            }

            node = null;
            edge = null;
            return;
        }
Example #9
0
        public void Render(IGraphics g, WorldTransform wt)
        {
            List <InternalTrackedCluster> trackedClusters = this.trackedClusters;

            float  vehicleHeading = (float)Services.VehicleStateService.Heading;
            PointF vehiclePos     = Utility.ToPointF(Services.VehicleStateService.Location);

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

            SizeF boxSize = new SizeF(2 * point_box_size, 2 * point_box_size);

            foreach (InternalTrackedCluster cluster in trackedClusters)
            {
                // determine cluster color
                Color clusterColor;
                switch (cluster.targetClass)
                {
                case SceneEstimatorTargetClass.TARGET_CLASS_CARLIKE:
                    clusterColor = carlikeColor;
                    break;

                case SceneEstimatorTargetClass.TARGET_CLASS_NOTCARLIKE:
                    clusterColor = notcarColor;
                    break;

                case SceneEstimatorTargetClass.TARGET_CLASS_UNKNOWN:
                default:
                    clusterColor = unknownColor;
                    break;
                }

                if (cluster.targetStatus == SceneEstimatorTargetStatusFlag.TARGET_STATE_DELETED)
                {
                    clusterColor = Color.FromArgb(deleted_alpha, clusterColor);
                }

                if (drawPoints)
                {
                    // render the points
                    IPen pen = g.CreatePen();
                    pen.Color = clusterColor;
                    pen.Width = nominal_pixel_size / wt.Scale;

                    for (int j = 0; j < cluster.points.Length; j++)
                    {
                        g.DrawRectangle(pen, new RectangleF(cluster.points[j], boxSize));
                    }
                }

                if (drawPolygon)
                {
                    IPen pen = g.CreatePen();
                    pen.Color = clusterColor;
                    pen.Width = nominal_pixel_size / wt.Scale;

                    g.DrawPolygon(pen, Utility.ToPointF(cluster.polygon));
                }

                // if we're stopped, draw an x at the center of the polygon
                if (cluster.isStopped)
                {
                    DrawingUtility.DrawControlPoint(g, cluster.polygon.GetCentroid(), Color.Red, null, ContentAlignment.BottomCenter, ControlPointStyle.LargeX, wt);
                }
                else
                {
                    // draw a vector pointing from the centroid of the polygon out
                }
            }

            g.ComeBackFromVehicleCoordinates();
        }
        public void Render(System.Drawing.Graphics g, WorldTransform t)
        {
            if (!this.snapToWaypoints || this.roadNetwork == null)
            {
                if (this.Current != null)
                {
                    LLACoord lla = GpsTools.XyToLlaDegrees(Current, projection);

                    string locString = Current.X.ToString("F6") + ", " + Current.Y.ToString("F6") + "\n" +
                                       lla.lat.ToString("F6") + ", " + lla.lon.ToString("F6") + "\n" + GpsTools.LlaDegreesToArcMinSecs(lla);

                    DrawingUtility.DrawControlPoint(this.Current, DrawingUtility.ColorToolPointAnalysis, locString,
                                                    ContentAlignment.BottomCenter, ControlPointStyle.SmallCircle, g, t);
                }

                if (Save != null && Save.Count > 0)
                {
                    foreach (Coordinates tmp in Save)
                    {
                        LLACoord lla = GpsTools.XyToLlaDegrees(tmp, projection);

                        string locString = tmp.X.ToString("F6") + ", " + tmp.Y.ToString("F6") + "\n" +
                                           lla.lat.ToString("F6") + ", " + lla.lon.ToString("F6") + "\n" + GpsTools.LlaDegreesToArcMinSecs(lla);

                        DrawingUtility.DrawControlPoint(tmp, DrawingUtility.ColorToolPointAnalysis, locString,
                                                        ContentAlignment.BottomCenter, ControlPointStyle.SmallCircle, g, t);
                    }
                }
            }
            else
            {
                if (this.Current != null)
                {
                    Coordinates c       = this.Current;
                    double      minDist = Double.MaxValue;
                    Coordinates?closest = null;

                    foreach (IArbiterWaypoint iaw in this.roadNetwork.ArbiterWaypoints.Values)
                    {
                        double d = iaw.Position.DistanceTo(c);
                        if (d < minDist && ((IDisplayObject)iaw).HitTest(c, (float)0.2, wt, DrawingUtility.DefaultFilter).Hit)
                        {
                            minDist = d;
                            closest = iaw.Position;
                        }
                    }

                    if (closest != null)
                    {
                        c = closest.Value;
                    }

                    LLACoord lla = GpsTools.XyToLlaDegrees(c, projection);

                    string locString = c.X.ToString("F6") + ", " + c.Y.ToString("F6") + "\n" +
                                       lla.lat.ToString("F6") + ", " + lla.lon.ToString("F6") + "\n" + GpsTools.LlaDegreesToArcMinSecs(lla);

                    DrawingUtility.DrawControlPoint(c, DrawingUtility.ColorToolPointAnalysis, locString,
                                                    ContentAlignment.BottomCenter, ControlPointStyle.SmallCircle, g, t);
                }
            }
        }
        /// <summary>
        /// What happens when we paint
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            // clear the background
            e.Graphics.Clear(BackColor);

            // center on tracked vehicle if exists
            if (this.tracked != null)
            {
                // Get the offset.
                Point point = new Point(this.ClientRectangle.Width / 2, this.ClientRectangle.Height / 2);

                // get screen po of vehicle
                PointF screenCarPos = this.transform.GetScreenPoint(this.tracked.Position);

                // Calculate change in Position
                double deltaX = ((double)screenCarPos.X) - point.X;
                double deltaY = ((double)screenCarPos.Y) - point.Y;

                // Update the world
                Coordinates tempCenter = WorldTransform.CenterPoint;
                tempCenter.X += deltaX / WorldTransform.Scale;
                tempCenter.Y -= deltaY / WorldTransform.Scale;
                WorldTransform.CenterPoint = tempCenter;
            }

            // save the graphics state
            GraphicsState gs = e.Graphics.Save();

            // set the drawing modes
            e.Graphics.SmoothingMode      = SmoothingMode.AntiAlias;       //.HighSpeed;//.HighQuality;
            e.Graphics.CompositingQuality = CompositingQuality.HighSpeed;  //.HighQuality;
            e.Graphics.InterpolationMode  = InterpolationMode.Bilinear;    //.Bicubic;
            e.Graphics.TextRenderingHint  = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;

            // set the transform
            e.Graphics.Transform = transform.GetTransform();

            // paint the display objects
            foreach (IDisplayObject obj in displayObjects)
            {
                // check if we should display the object
                if (obj.ShouldDraw())
                {
                    // render each object
                    obj.Render(e.Graphics, transform);
                }
            }

            // render ai vehicle
            if (!this.DesignMode && this.aiVehicle != null && this.aiVehicle.State != null && this.aiVehicle.ShouldDraw())
            {
                this.aiVehicle.Render(e.Graphics, transform);
            }

            // render ai information
            if (!this.DesignMode && RemoraCommon.aiInformation.ShouldDraw())
            {
                RemoraCommon.aiInformation.Render(e.Graphics, transform);
            }

            // render current tool
            if (!this.DesignMode && this.CurrentEditorTool != null && this.CurrentEditorTool.ShouldDraw())
            {
                this.CurrentEditorTool.Render(e.Graphics, transform);
            }

            // render current tool
            if (!this.DesignMode && this.SecondaryEditorTool != null && this.SecondaryEditorTool.ShouldDraw())
            {
                this.SecondaryEditorTool.Render(e.Graphics, transform);
            }

            // render observed vehicles
            if (!this.DesignMode && RemoraCommon.Communicator.GetObservedVehicles() != null)
            {
                SceneEstimatorTrackedClusterCollection setcc = RemoraCommon.Communicator.GetObservedVehicles();
                for (int i = 0; i < setcc.clusters.Length; i++)
                {
                    SensedVehicleDisplay svd = new SensedVehicleDisplay(setcc.clusters[i]);
                    svd.Render(e.Graphics, this.WorldTransform);
                }
            }

            if (!this.DesignMode)
            {
                // render driver side sick
                VehicleState state = RemoraCommon.Communicator.GetVehicleState();
                if (state != null)
                {
                    Coordinates   dvec      = state.Front - state.Position;
                    Coordinates   driverVec = dvec.Rotate90();
                    SideObstacles dsobs     = RemoraCommon.Communicator.GetSideObstacles(SideObstacleSide.Driver);
                    if (dsobs != null)
                    {
                        foreach (SideObstacle so in dsobs.obstacles)
                        {
                            if (so.height > 0.7)
                            {
                                Coordinates cVec = state.Position + driverVec.Normalize(so.distance);
                                DrawingUtility.DrawControlPoint(cVec, Color.Black, null, ContentAlignment.MiddleCenter, ControlPointStyle.LargeX, e.Graphics, this.WorldTransform);
                            }
                        }
                    }

                    // render driver side sick
                    Coordinates   pvec    = state.Front - state.Position;
                    Coordinates   passVec = dvec.RotateM90();
                    SideObstacles psobs   = RemoraCommon.Communicator.GetSideObstacles(SideObstacleSide.Passenger);
                    if (psobs != null)
                    {
                        foreach (SideObstacle so in psobs.obstacles)
                        {
                            if (so.height > 0.7)
                            {
                                Coordinates cVec = state.Position + passVec.Normalize(so.distance);
                                DrawingUtility.DrawControlPoint(cVec, Color.Black, null, ContentAlignment.MiddleCenter, ControlPointStyle.LargeX, e.Graphics, this.WorldTransform);
                            }
                        }
                    }
                }
            }

            // render observed obstacles
            if (!this.DesignMode && RemoraCommon.Communicator.GetVehicleState() != null && RemoraCommon.RoadNetwork != null)
            {
                // set and render
                obstacleDisplay.untrackedClusters = RemoraCommon.Communicator.GetObservedObstacles();
                obstacleDisplay.trackedClusters   = RemoraCommon.Communicator.GetObservedVehicles();
                obstacleDisplay.Render(e.Graphics, this.WorldTransform);
            }

            // restore the graphics state
            e.Graphics.Restore(gs);
        }
        /// <summary>
        /// Called when the bar is exposed (drawn).
        /// </summary>
        /// <param name="exposeEvent">The drawing event..</param>
        /// <returns></returns>
        protected override bool OnExposeEvent(EventExpose exposeEvent)
        {
            // Figure out the area we are rendering into. We subtract one
            // from the width and height because of rounding causes one-pixel
            // borders off the bottom and right edges.
            Rectangle area      = exposeEvent.Region.Clipbox;
            var       cairoArea = new Cairo.Rectangle(
                area.X, area.Y, area.Width - 1, area.Height - 1);

            using (Context cairoContext = CairoHelper.Create(exposeEvent.Window))
            {
                // Create a render context.
                var renderContext = new RenderContext(cairoContext);
                renderContext.RenderRegion = cairoArea;

                // Paint the background of the entire indicator bar.
                BlockStyle backgroundStyle = Theme.RegionStyles[BackgroundRegionName]
                                             ?? new RegionBlockStyle();
                DrawingUtility.DrawLayout(
                    EditorView, renderContext, cairoArea, backgroundStyle);

                // Show the visible area, if we have one.
                BlockStyle visibleStyle = Theme.RegionStyles[VisibleRegionName];
                double     barX         = area.X + backgroundStyle.Left + 0.5;
                double     barWidth     = area.Width - backgroundStyle.Width - 1;
                double     barY         = area.Y + backgroundStyle.Top + 0.5;

                if (visibleStyle != null)
                {
                    // Figure out the area and adjust the bar variables with this style.
                    var visibleArea = new Cairo.Rectangle(
                        barX,
                        barY,
                        barWidth,
                        indicatorLinesUsed * Theme.IndicatorPixelHeight + visibleStyle.Height);

                    barX     += visibleStyle.Left;
                    barWidth -= visibleStyle.Width;
                    barY     += visibleStyle.Top;

                    // Draw the style's elements.
                    DrawingUtility.DrawLayout(
                        EditorView, renderContext, visibleArea, visibleStyle);
                }

                // Draw all the indicator lines on the display.
                cairoContext.LineWidth = EditorView.Theme.IndicatorPixelHeight;
                cairoContext.Antialias = Antialias.None;

                for (int index = 0;
                     index < indicatorLinesUsed;
                     index++)
                {
                    // Make sure the line has been processed and it visible.
                    IndicatorLine indicatorLine = indicatorLines[index];

                    if (!indicatorLine.NeedIndicators &&
                        indicatorLine.Visible)
                    {
                        indicatorLine.Draw(EditorView, cairoContext, barX, barY, barWidth);
                    }

                    // Shift the y-coordinate down.
                    barY += EditorView.Theme.IndicatorPixelHeight;
                }
            }

            // Return the render.
            return(base.OnExposeEvent(exposeEvent));
        }
Example #13
0
        /// <summary>
        /// Called when the widget is exposed or drawn.
        /// </summary>
        /// <param name="e">The e.</param>
        /// <returns></returns>
        protected override bool OnExposeEvent(EventExpose e)
        {
            // Figure out the area we are rendering into.
            Gdk.Rectangle area      = e.Region.Clipbox;
            var           cairoArea = new Rectangle(area.X, area.Y, area.Width, area.Height);

            using (Context cairoContext = CairoHelper.Create(e.Window))
            {
                // Create a render context.
                var renderContext = new RenderContext(cairoContext);
                renderContext.RenderRegion = cairoArea;

                // If we don't have a buffer at this point, don't render anything.
                if (Renderer == null ||
                    LineBuffer == null)
                {
                    return(true);
                }

                // Paint the background color of the window.
                RegionBlockStyle backgroundStyle =
                    Theme.RegionStyles[Theme.BackgroundRegionStyleName];
                DrawingUtility.DrawLayout(this, renderContext, cairoArea, backgroundStyle);

                // Reset the layout and its properties.
                Renderer.Width = area.Width - margins.Width;

                // Figure out the viewport area we'll be drawing.
                int offsetY = 0;

                if (verticalAdjustment != null)
                {
                    offsetY += (int)verticalAdjustment.Value;
                }

                var viewArea = new Rectangle(
                    area.X, area.Y + offsetY, area.Width, area.Height);

                // Determine the line range visible in the given area.
                int startLine,
                    endLine;
                Renderer.GetLineLayoutRange(viewArea, out startLine, out endLine);

                // Determine where the first line actually starts.
                int startLineY = 0;

                if (startLine > 0)
                {
                    startLineY = Renderer.GetLineLayoutHeight(0, startLine - 1);
                }

                // Go through the lines and draw each one in the correct position.
                double currentY = startLineY - offsetY;

                for (int lineIndex = startLine;
                     lineIndex <= endLine;
                     lineIndex++)
                {
                    // Figure out if we are on the current line.
                    var  lineContexts = LineContexts.None;
                    bool currentLine  = false;

                    if (lineIndex == caret.Position.LinePosition)
                    {
                        // Add the curent line to the context.
                        lineContexts |= LineContexts.CurrentLine;
                        currentLine   = true;
                    }

                    // Pull out the layout and style since we'll use it.
                    Layout         layout = Renderer.GetLineLayout(lineIndex, lineContexts);
                    LineBlockStyle style  = Renderer.GetLineStyle(lineIndex, lineContexts);

                    // Get the extents for that line.
                    int layoutWidth,
                        layoutHeight;
                    layout.GetPixelSize(out layoutWidth, out layoutHeight);

                    // Figure out the height of the line including padding.
                    double height = layoutHeight + style.Height;

                    if (currentLine)
                    {
                        // If we have a full-line background color, display it.
                        RegionBlockStyle currentLineStyle =
                            Theme.RegionStyles[Theme.CurrentLineRegionStyleName];

                        if (currentLineStyle != null)
                        {
                            var lineArea = new Rectangle(TextX, currentY, TextWidth, height);

                            DrawingUtility.DrawLayout(
                                this, renderContext, lineArea, currentLineStyle);
                        }

                        // If we have a wrapped line background color, draw it.
                        RegionBlockStyle currentWrappedLineStyle =
                            Theme.RegionStyles[Theme.CurrentWrappedLineRegionStyleName];

                        if (currentWrappedLineStyle != null)
                        {
                            // Get the wrapped line for the caret's position.
                            LayoutLine      wrappedLine = caret.Position.GetWrappedLine(this);
                            Pango.Rectangle wrappedLineExtents;

                            wrappedLine.GetPixelExtents(out wrappedLineExtents);

                            // Draw the current wrapped line index.
                            var wrappedLineArea = new Rectangle(
                                TextX,
                                currentY + wrappedLineExtents.Y + style.Top,
                                TextWidth,
                                wrappedLineExtents.Height);

                            DrawingUtility.DrawLayout(
                                this, renderContext, wrappedLineArea, currentWrappedLineStyle);
                        }
                    }

                    // Draw the current line along with wrapping and padding.
                    DrawingUtility.DrawLayout(
                        this,
                        renderContext,
                        new Rectangle(TextX, currentY, TextWidth, height),
                        layout,
                        style);

                    // Render out the margin renderers.
                    margins.Draw(
                        this, renderContext, lineIndex, new PointD(0, currentY), height, style);

                    // Move down a line.
                    currentY += height;
                }

                // Draw the caret on the screen, but only if we have focus.
                if (IsFocus)
                {
                    caret.Draw(renderContext);
                }

                // Show the scroll region, if requested.
                if (editorViewSettings.ShowScrollPadding)
                {
                    cairoContext.Color = new Color(1, 0.5, 0.5);
                    cairoContext.Rectangle(scrollPaddingRegion);
                    cairoContext.Stroke();
                }
            }

            return(true);
        }
Example #14
0
 public void Render(System.Drawing.Graphics g, WorldTransform t)
 {
     DrawingUtility.DrawColoredControlLine(DrawingUtility.ColorArbiterUserPartition, System.Drawing.Drawing2D.DashStyle.Dash,
                                           this.InitialGeneric.Position, this.FinalGeneric.Position, g, t);
 }
Example #15
0
        public void Render(System.Drawing.Graphics g, WorldTransform t)
        {
            ArbiterInformation tmpInfo = information;

            if (tmpInfo != null)
            {
                lock (tmpInfo)
                {
                    if (tmpInfo.Route1 != null && tmpInfo.Route1.RoutePlan != null && DrawingUtility.DrawNavigationBestRoute)
                    {
                        Color c = DrawingUtility.ColorNavigationBest;

                        for (int j = 0; j < tmpInfo.Route1.RoutePlan.Count; j++)
                        {
                            if (j == 0 && RemoraCommon.Communicator.GetVehicleState() != null)
                            {
                                DrawingUtility.DrawColoredControlLine(c, System.Drawing.Drawing2D.DashStyle.Solid, RemoraCommon.Communicator.GetVehicleState().Position, tmpInfo.Route1.RoutePlan[j], g, t);
                            }
                            else if (RemoraCommon.Communicator.GetVehicleState() != null)
                            {
                                DrawingUtility.DrawColoredControlLine(c, System.Drawing.Drawing2D.DashStyle.Solid, tmpInfo.Route1.RoutePlan[j - 1], tmpInfo.Route1.RoutePlan[j], g, t);
                            }
                        }
                    }


                    foreach (ArbiterInformationDisplayObject aido in tmpInfo.DisplayObjects)
                    {
                        if (aido.Type == ArbiterInformationDisplayObjectType.uTurnPolygon)
                        {
                            Polygon p = (Polygon)aido.DisplayObject;
                            if (p.Count > 1)
                            {
                                for (int i = 1; i < p.Count; i++)
                                {
                                    DrawingUtility.DrawColoredControlLine(Color.Orange, System.Drawing.Drawing2D.DashStyle.Solid, p[i - 1], p[i], g, t);
                                }

                                DrawingUtility.DrawColoredControlLine(Color.Orange, System.Drawing.Drawing2D.DashStyle.Solid, p[0], p[p.Count - 1], g, t);
                            }
                        }
                        else if (aido.Type == ArbiterInformationDisplayObjectType.leftBound)
                        {
                            LineList ll = (LineList)aido.DisplayObject;
                            if (ll.Count > 1)
                            {
                                for (int i = 1; i < ll.Count; i++)
                                {
                                    DrawingUtility.DrawColoredControlLine(Color.Blue, System.Drawing.Drawing2D.DashStyle.Solid, ll[i - 1], ll[i], g, t);
                                }
                            }
                        }
                        else if (aido.Type == ArbiterInformationDisplayObjectType.rightBound)
                        {
                            LineList ll = (LineList)aido.DisplayObject;
                            if (ll.Count > 1)
                            {
                                for (int i = 1; i < ll.Count; i++)
                                {
                                    DrawingUtility.DrawColoredControlLine(Color.Red, System.Drawing.Drawing2D.DashStyle.Solid, ll[i - 1], ll[i], g, t);
                                }
                            }
                        }
                    }
                }
            }
        }
Example #16
0
        protected void GenerateCurve()
        {
            //Make sure we have all the info we need
            if (Whisker == null || Whisker.WhiskerPoints == null)
            {
                return;
            }

            if (Whisker.WhiskerPoints.Length == 0)
            {
                return;
            }

            if (Whisker.Parent.OriginalWidth == 0 || Whisker.Parent.OriginalHeight == 0)
            {
                return;
            }

            //Calculate Control Points
            IWhiskerPoint firstPoint = Whisker.WhiskerPoints[0].Clone();

            ControlPoints    = new IWhiskerPoint[Whisker.WhiskerPoints.Length];
            ControlPoints[0] = firstPoint;

            double videoWidth  = Whisker.Parent.OriginalWidth;
            double videoHeight = Whisker.Parent.OriginalHeight;

            if (ControlPoints.Length == 2)
            {
                IWhiskerPoint lWhiskerPoint1 = Whisker.WhiskerPoints[1].Clone();
                ControlPoints[1] = lWhiskerPoint1;
                TargetPoint      = GetTValuePointForLinear();
            }

            if (ControlPoints.Length == 3)
            {
                IWhiskerPoint qWhiskerPoint1 = Whisker.WhiskerPoints[1].Clone();
                IWhiskerPoint qWhiskerPoint2 = Whisker.WhiskerPoints[2].Clone();

                Point[] points = new Point[3];
                points[0] = new Point(firstPoint.XRatio * videoWidth, firstPoint.YRatio * videoHeight);
                points[1] = new Point(qWhiskerPoint1.XRatio * videoWidth, qWhiskerPoint1.YRatio * videoHeight);
                points[2] = new Point(qWhiskerPoint2.XRatio * videoWidth, qWhiskerPoint2.YRatio * videoHeight);

                Point point1;
                DrawingUtility.GetControlPointsForQuadraticBezier(points, out point1);

                qWhiskerPoint1.XRatio = point1.X / videoWidth;
                qWhiskerPoint1.YRatio = point1.Y / videoHeight;

                ControlPoints[1] = qWhiskerPoint1;
                ControlPoints[2] = qWhiskerPoint2;
                TargetPoint      = GetTValuePointForQuadratic();
            }

            if (ControlPoints.Length == 4)
            {
                IWhiskerPoint cWhiskerPoint1 = Whisker.WhiskerPoints[1].Clone();
                IWhiskerPoint cWhiskerPoint2 = Whisker.WhiskerPoints[2].Clone();
                IWhiskerPoint cWhiskerPoint3 = Whisker.WhiskerPoints[3].Clone();

                Point[] points = new Point[4];
                points[0] = new Point(firstPoint.XRatio * videoWidth, firstPoint.YRatio * videoHeight);
                points[1] = new Point(cWhiskerPoint1.XRatio * videoWidth, cWhiskerPoint1.YRatio * videoHeight);
                points[2] = new Point(cWhiskerPoint2.XRatio * videoWidth, cWhiskerPoint2.YRatio * videoHeight);
                points[3] = new Point(cWhiskerPoint3.XRatio * videoWidth, cWhiskerPoint3.YRatio * videoHeight);

                Point point1, point2;
                DrawingUtility.GetControlPointsForCubicBezier(points, out point1, out point2);

                cWhiskerPoint1.XRatio = point1.X / videoWidth;
                cWhiskerPoint1.YRatio = point1.Y / videoHeight;
                cWhiskerPoint2.XRatio = point2.X / videoWidth;
                cWhiskerPoint2.YRatio = point2.Y / videoHeight;

                ControlPoints[1] = cWhiskerPoint1;
                ControlPoints[2] = cWhiskerPoint2;
                ControlPoints[3] = cWhiskerPoint3;
                TargetPoint      = GetTValuePointForCubic();
            }
        }
        /// <summary>
        /// Renders the grid
        /// </summary>
        /// <param name="g"></param>
        /// <param name="t"></param>
        public void Render(System.Drawing.Graphics g, WorldTransform t)
        {
            // check if we are showinghte grid
            Coordinates wll = t.WorldLowerLeft;
            Coordinates wur = t.WorldUpperRight;

            // sapcing
            double tmpSpacing = (double)spacing;

            // num x lines
            double xNum = Math.Ceiling(Math.Abs(wll.X - wur.X) / tmpSpacing);

            // num y lines
            double yNum = Math.Ceiling(Math.Abs(wll.Y - wur.Y) / tmpSpacing);

            // check length
            if (xNum < 400 && yNum < 400)
            {
                // pen width
                float pw = 1.25f / t.Scale;

                // pen
                using (Pen p = new Pen(color, pw))
                {
                    // draw x lines
                    for (double i = Math.Floor(wll.X / tmpSpacing) * tmpSpacing; i <= Math.Ceiling(wur.X / tmpSpacing) * tmpSpacing; i += tmpSpacing)
                    {
                        g.DrawLine(p, DrawingUtility.ToPointF(new Coordinates(i, wur.Y)), DrawingUtility.ToPointF(new Coordinates(i, wll.Y)));
                    }

                    // draw y lines
                    for (double j = Math.Floor(wll.Y / tmpSpacing) * tmpSpacing; j <= Math.Ceiling(wur.Y / tmpSpacing) * tmpSpacing; j += tmpSpacing)
                    {
                        g.DrawLine(p, DrawingUtility.ToPointF(new Coordinates(wll.X, j)), DrawingUtility.ToPointF(new Coordinates(wur.X, j)));
                    }
                }
            }

            /*PointF ll = new PointF((float)wll.X, (float)wll.Y);
             * PointF ur = new PointF((float)wur.X, (float)wur.Y);
             *
             * float startX = (float)Math.Floor(wll.X / spacing) * spacing;
             * float endX = (float)Math.Ceiling(wur.X / spacing) * spacing;
             * float startY = (float)Math.Floor(wll.Y / spacing) * spacing;
             * float endY = (float)Math.Ceiling(wur.Y / spacing) * spacing;
             *
             * using (Pen p = new Pen(color, 1 / t.Scale))
             * {
             *      if (endX - startX / spacing < 400 && endY - startY / spacing < 400)
             *      {
             *              for (float x = startX; x <= endX; x += spacing)
             *              {
             *                      g.DrawLine(p, x, ll.Y, x, ur.Y);
             *              }
             *
             *              for (float y = startY; y <= endY; y += spacing)
             *              {
             *                      g.DrawLine(p, ll.X, y, ur.X, y);
             *              }
             *      }
             * }*/
        }
Example #18
0
        public void Render(System.Drawing.Graphics g, WorldTransform t)
        {
            Polygon     p      = new Polygon();
            Coordinates tCoord = new Coordinates();
            Coordinates loc    = RemoraCommon.Communicator.GetVehicleState().Position;

            // body transformation matrix
            Matrix bodyTrans = new Matrix();

            bodyTrans.Rotate((float)(RemoraCommon.Communicator.GetVehicleState().Heading.ToDegrees()));
            bodyTrans.Translate((float)loc.X, (float)loc.Y, MatrixOrder.Append);

            // save original world transformation matrix
            Matrix origTrans = g.Transform.Clone();

            bodyTrans.Multiply(g.Transform, MatrixOrder.Append);

            // set the new transform
            g.Transform = bodyTrans;

            if (DrawingUtility.DrawSimObstacles)
            {
                if (untrackedClusters != null && untrackedClusters.clusters != null)
                {
                    for (int i = 0; i < untrackedClusters.clusters.Length; i++)
                    {
                        if (untrackedClusters.clusters[i].points.Length > 4)
                        {
                            tCoord = untrackedClusters.clusters[i].points[0];
                            if (Math.Abs(tCoord.X) < 60 && Math.Abs(tCoord.Y) < 60)
                            {
                                p = Polygon.GrahamScan(new List <Coordinates>(untrackedClusters.clusters[i].points));
                                DrawingUtility.DrawControlPolygon(p, Color.Purple, DashStyle.Solid, g, t);
                            }
                        }
                    }
                }
            }

            if (DrawingUtility.DrawSimCars)
            {
                if (trackedClusters != null && trackedClusters.clusters != null)
                {
                    for (int i = 0; i < trackedClusters.clusters.Length; i++)
                    {
                        Color c;

                        if (this.trackedClusters.clusters[i].statusFlag == SceneEstimatorTargetStatusFlag.TARGET_STATE_ACTIVE)
                        {
                            if (this.trackedClusters.clusters[i].targetClass == SceneEstimatorTargetClass.TARGET_CLASS_CARLIKE)
                            {
                                if (this.trackedClusters.clusters[i].isStopped)
                                {
                                    c = Color.Red;
                                }
                                else
                                {
                                    c = DrawingUtility.ColorSimTrafficCar;
                                }
                            }
                            else
                            {
                                c = Color.Pink;
                            }
                        }
                        else
                        {
                            c = DrawingUtility.ColorSimDeletedCar;
                        }

                        bool draw = this.trackedClusters.clusters[i].statusFlag == SceneEstimatorTargetStatusFlag.TARGET_STATE_ACTIVE ?
                                    DrawingUtility.DrawSimCars :
                                    DrawingUtility.DrawSimCars && DrawingUtility.DrawSimCarDeleted;

                        if (draw)
                        {
                            if (trackedClusters.clusters[i].relativePoints.Length > 2)
                            {
                                tCoord = trackedClusters.clusters[i].relativePoints[0];
                                if (Math.Abs(tCoord.X) < t.ScreenSize.Width / 1.5 && Math.Abs(tCoord.Y) < t.ScreenSize.Height / 1.5)
                                {
                                    p = Polygon.GrahamScan(new List <Coordinates>(trackedClusters.clusters[i].relativePoints));
                                    DrawingUtility.DrawControlPolygon(p, c, DashStyle.Solid, g, t);
                                }
                            }
                        }
                    }
                }
            }

            g.Transform = origTrans;
        }
        public void Click(Coordinates c)
        {
            if (this.zt.Mode == ZoneToolboxMode.Selection)
            {
                this.zt.SelectZone(c);
            }
            else if (this.Mode == ZoneToolboxMode.NavNodes && this.zt.current != null)
            {
                // save undo point
                this.ed.SaveUndoPoint();

                // check if we hit any of hte edges or nodes part of the zone
                ArbiterZone az = this.zt.current;

                // check if hit node or edge
                NavigableEdge  ne;
                INavigableNode nn;
                this.NavigationHitTest(c, out nn, out ne);

                if (nn != null)
                {
                    // create new node
                    INavigableNode aznn = nn;

                    if (this.PreviousNode != null)
                    {
                        // create new edges
                        NavigableEdge newE1 = new NavigableEdge(true, this.zt.current, false, null, new List <IConnectAreaWaypoints>(), this.PreviousNode, aznn);
                        this.PreviousNode.OutgoingConnections.Add(newE1);
                        this.zt.current.NavigableEdges.Add(newE1);
                    }

                    this.PreviousNode = aznn;
                }
                else if (ne != null)
                {
                    // remove old
                    this.zt.current.NavigableEdges.Remove(ne);

                    // remove all references
                    ne.Start.OutgoingConnections.Remove(ne);

                    // create new node
                    ArbiterZoneNavigableNode aznn = new ArbiterZoneNavigableNode(c);

                    // create new edges
                    NavigableEdge newE1 = new NavigableEdge(true, this.zt.current, false, null, new List <IConnectAreaWaypoints>(), ne.Start, aznn);
                    NavigableEdge newE2 = new NavigableEdge(true, this.zt.current, false, null, new List <IConnectAreaWaypoints>(), aznn, ne.End);

                    // add edges
                    ne.Start.OutgoingConnections.Add(newE1);
                    aznn.OutgoingConnections.Add(newE2);

                    // add all to lists
                    this.zt.current.NavigableEdges.Add(newE1);
                    this.zt.current.NavigableEdges.Add(newE2);
                    this.zt.current.NavigationNodes.Add(aznn);

                    if (this.PreviousNode != null)
                    {
                        NavigableEdge newE3 = new NavigableEdge(true, this.zt.current, false, null, new List <IConnectAreaWaypoints>(), this.PreviousNode, aznn);
                        this.PreviousNode.OutgoingConnections.Add(newE3);
                        this.zt.current.NavigableEdges.Add(newE3);
                    }

                    this.PreviousNode = aznn;
                }
                else
                {
                    // create new node
                    ArbiterZoneNavigableNode aznn = new ArbiterZoneNavigableNode(c);

                    if (this.PreviousNode != null)
                    {
                        // create new edges
                        NavigableEdge newE1 = new NavigableEdge(true, this.zt.current, false, null, new List <IConnectAreaWaypoints>(), this.PreviousNode, aznn);
                        this.PreviousNode.OutgoingConnections.Add(newE1);
                        this.zt.current.NavigableEdges.Add(newE1);
                    }

                    this.PreviousNode = aznn;
                    this.zt.current.NavigationNodes.Add(aznn);
                }
            }
            else if (this.zt.Mode == ZoneToolboxMode.StayOut && this.zt.current != null)
            {
                if (this.WrappingHelpers.Count == 0)
                {
                    this.WrappingHelpers.Add(c);
                }
                else
                {
                    // Determine size of bounding box
                    float scaled_offset = 1 / this.rd.WorldTransform.Scale;

                    // invert the scale
                    float scaled_size = DrawingUtility.cp_large_size;

                    // assume that the world transform is currently applied correctly to the graphics
                    RectangleF rect = new RectangleF((float)c.X - scaled_size / 2, (float)c.Y - scaled_size / 2, scaled_size, scaled_size);

                    if (rect.Contains(DrawingUtility.ToPointF(this.WrappingHelpers[0])) &&
                        c.DistanceTo(this.WrappingHelpers[0]) < 1)
                    {
                        ed.SaveUndoPoint();
                        Polygon p = new Polygon(this.WrappingHelpers);
                        this.zt.current.StayOutAreas.Add(p);
                        this.WrappingHelpers = new List <Coordinates>();
                    }
                    else
                    {
                        this.WrappingHelpers.Add(c);
                    }
                }

                this.rd.Invalidate();
            }
        }