Example #1
1
        private void ribbonButton49_Click(object sender, EventArgs e)
        {
            if (ellipsePrimitive == null)
            {
                GeoPoint pos = new GeoPoint();
                pos.x = 116.3;
                pos.y = 39.9;
                pos.srs = m_earthMap.getSRS();

                Linear radiusMajor = new Linear();
                radiusMajor.set( 250, UnitsType.UNIT_MILES );

                Linear radiusMinor = new Linear();
                radiusMinor.set( 100, UnitsType.UNIT_MILES );

                Angular rotationAngle = new Angular();
                rotationAngle.set( 0, UnitsType.UNIT_DEGREES );

                Angular arcStart = new Angular();
                arcStart.set( 45.0, UnitsType.UNIT_DEGREES );

                Angular arcEnd = new Angular();
                arcEnd.set( 360.0 - 45.0, UnitsType.UNIT_DEGREES );

                ellipsePrimitive = new EllipsePrimitive();
                ellipsePrimitive.setPosition( pos );
                ellipsePrimitive.setRadiusMajor( radiusMajor );
                ellipsePrimitive.setRadiusMinor(radiusMinor);
                ellipsePrimitive.setRotationAngle(rotationAngle);
                ellipsePrimitive.setArcStart(arcStart);
                ellipsePrimitive.setArcEnd(arcEnd);
                ellipsePrimitive.setPie(true);
                m_earthRoot.addChild( ellipsePrimitive);
            }
        }
Example #2
0
        private static IGraphic CreateCircle(PointF center, float radius)
        {
            var circle = new EllipsePrimitive();
            var radial = new SizeF(radius, radius);

            circle.TopLeft     = center - radial;
            circle.BottomRight = center + radial;
            return(circle);
        }
Example #3
0
 public DicomEllipseGraphic()
 {
     base.Graphics.Add(_ellipse = new EllipsePrimitive());
     _points = new PointsList(this);
     _points.Add(PointF.Empty);
     _points.Add(PointF.Empty);
     _points.Add(PointF.Empty);
     _points.Add(PointF.Empty);
     _points.PointChanged += OnPointChanged;
 }
        protected override Roi CreateRoiFromGraphic(IOverlayGraphicsProvider overlayGraphics, RectangleF shapeData)
        {
            EllipsePrimitive graphic = new EllipsePrimitive();

            overlayGraphics.OverlayGraphics.Add(graphic);
            graphic.CoordinateSystem = CoordinateSystem.Source;
            graphic.TopLeft          = shapeData.Location;
            graphic.BottomRight      = shapeData.Location + shapeData.Size;
            graphic.ResetCoordinateSystem();
            return(graphic.GetRoi());
        }
Example #5
0
        public void TestPointNearZero()
        {
            float  a      = 2.5F;
            float  b      = 1.25F;
            PointF center = new PointF(3F, 2F);
            PointF test   = new PointF(3.01F, 2.01F);

            PointF intersection = EllipsePrimitive.IntersectEllipseAndLine(a, b, center, test);

            VerifyPointOnEllipse(a, b, center, intersection);
        }
Example #6
0
        // Token: 0x0600420E RID: 16910 RVA: 0x0014FD20 File Offset: 0x0014E120
        public override void GenerateColliderGeometry()
        {
            Mesh colliderMesh = base.GetColliderMesh();

            if (colliderMesh)
            {
                colliderMesh.Clear();
                EllipsePrimitive.GenerateGeometry(colliderMesh, this.radius0, this.radius1, this.segments);
                base.RefreshMeshCollider();
            }
            base.GenerateColliderGeometry();
        }
Example #7
0
        public void TestPointVeryCloseToZero()
        {
            float  a      = 2.5F;
            float  b      = 1.25F;
            PointF center = new PointF(3F, 2F);
            PointF test   = new PointF(3.0001F, 2.0001F);

            PointF intersection = EllipsePrimitive.IntersectEllipseAndLine(a, b, center, test);

            //intersection is at center.
            Assert.IsTrue(FloatComparer.AreEqual(center, intersection), "ellipse intersection point is not correct!");
        }
Example #8
0
        public void TestMinorAxisZero()
        {
            float  a      = 2.5F;
            float  b      = 0F;
            PointF center = new PointF(3F, 2F);
            PointF test   = new PointF(13F, 7F);

            PointF intersection = EllipsePrimitive.IntersectEllipseAndLine(a, b, center, test);

            //intersection is at center.
            Assert.IsTrue(FloatComparer.AreEqual(center, intersection), "ellipse intersection point is not correct!");
        }
Example #9
0
		public void TestEllipseGetRoi()
		{
			// test null ellipse
			{
				var ellipse = new EllipsePrimitive();
				ellipse.TopLeft = new PointF(5, 5);
				ellipse.BottomRight = new PointF(5, 5);
				var roi = ellipse.GetRoi();
				Assert.IsNotNull(roi, "EllipsePrimitive.GetRoi() should never return null (rect = {0})", ellipse.Rectangle);
				AssertAreEqual(new RectangleF(5, 5, 0, 0), roi.BoundingBox, _dimensionTolerance, "EllipsePrimitive.GetRoi() returned wrong ROI (ellipse = {0})", ellipse.Rectangle);
			}

			// test positive ellipse
			{
				var ellipse = new EllipsePrimitive();
				ellipse.TopLeft = new PointF(0, 0);
				ellipse.BottomRight = new PointF(1, 1);
				var roi = ellipse.GetRoi();
				Assert.IsNotNull(roi, "EllipsePrimitive.GetRoi() should never return null (rect = {0})", ellipse.Rectangle);
				AssertAreEqual(new RectangleF(0, 0, 1, 1), roi.BoundingBox, _dimensionTolerance, "EllipsePrimitive.GetRoi() returned wrong ROI (ellipse = {0})", ellipse.Rectangle);
			}

			// test inverted ellipse
			{
				var ellipse = new EllipsePrimitive();
				ellipse.TopLeft = new PointF(5, 5);
				ellipse.BottomRight = new PointF(-1, -1);
				var roi = ellipse.GetRoi();
				Assert.IsNotNull(roi, "EllipsePrimitive.GetRoi() should never return null (rect = {0})", ellipse.Rectangle);
				AssertAreEqual(new RectangleF(-1, -1, 6, 6), roi.BoundingBox, _dimensionTolerance, "EllipsePrimitive.GetRoi() returned wrong ROI (ellipse = {0})", ellipse.Rectangle);
			}

			// test negative width ellipse
			{
				var ellipse = new EllipsePrimitive();
				ellipse.TopLeft = new PointF(5, 5);
				ellipse.BottomRight = new PointF(-1, 6);
				var roi = ellipse.GetRoi();
				Assert.IsNotNull(roi, "EllipsePrimitive.GetRoi() should never return null (rect = {0})", ellipse.Rectangle);
				AssertAreEqual(new RectangleF(-1, 5, 6, 1), roi.BoundingBox, _dimensionTolerance, "EllipsePrimitive.GetRoi() returned wrong ROI (ellipse = {0})", ellipse.Rectangle);
			}

			// test negative height ellipse
			{
				var ellipse = new EllipsePrimitive();
				ellipse.TopLeft = new PointF(5, 5);
				ellipse.BottomRight = new PointF(6, -1);
				var roi = ellipse.GetRoi();
				Assert.IsNotNull(roi, "EllipsePrimitive.GetRoi() should never return null (rect = {0})", ellipse.Rectangle);
				AssertAreEqual(new RectangleF(5, -1, 1, 6), roi.BoundingBox, _dimensionTolerance, "EllipsePrimitive.GetRoi() returned wrong ROI (ellipse = {0})", ellipse.Rectangle);
			}
		}
        public void TestEllipseGetRoi()
        {
            // test null ellipse
            {
                var ellipse = new EllipsePrimitive();
                ellipse.TopLeft     = new PointF(5, 5);
                ellipse.BottomRight = new PointF(5, 5);
                var roi = ellipse.GetRoi();
                Assert.IsNotNull(roi, "EllipsePrimitive.GetRoi() should never return null (rect = {0})", ellipse.Rectangle);
                AssertAreEqual(new RectangleF(5, 5, 0, 0), roi.BoundingBox, _dimensionTolerance, "EllipsePrimitive.GetRoi() returned wrong ROI (ellipse = {0})", ellipse.Rectangle);
            }

            // test positive ellipse
            {
                var ellipse = new EllipsePrimitive();
                ellipse.TopLeft     = new PointF(0, 0);
                ellipse.BottomRight = new PointF(1, 1);
                var roi = ellipse.GetRoi();
                Assert.IsNotNull(roi, "EllipsePrimitive.GetRoi() should never return null (rect = {0})", ellipse.Rectangle);
                AssertAreEqual(new RectangleF(0, 0, 1, 1), roi.BoundingBox, _dimensionTolerance, "EllipsePrimitive.GetRoi() returned wrong ROI (ellipse = {0})", ellipse.Rectangle);
            }

            // test inverted ellipse
            {
                var ellipse = new EllipsePrimitive();
                ellipse.TopLeft     = new PointF(5, 5);
                ellipse.BottomRight = new PointF(-1, -1);
                var roi = ellipse.GetRoi();
                Assert.IsNotNull(roi, "EllipsePrimitive.GetRoi() should never return null (rect = {0})", ellipse.Rectangle);
                AssertAreEqual(new RectangleF(-1, -1, 6, 6), roi.BoundingBox, _dimensionTolerance, "EllipsePrimitive.GetRoi() returned wrong ROI (ellipse = {0})", ellipse.Rectangle);
            }

            // test negative width ellipse
            {
                var ellipse = new EllipsePrimitive();
                ellipse.TopLeft     = new PointF(5, 5);
                ellipse.BottomRight = new PointF(-1, 6);
                var roi = ellipse.GetRoi();
                Assert.IsNotNull(roi, "EllipsePrimitive.GetRoi() should never return null (rect = {0})", ellipse.Rectangle);
                AssertAreEqual(new RectangleF(-1, 5, 6, 1), roi.BoundingBox, _dimensionTolerance, "EllipsePrimitive.GetRoi() returned wrong ROI (ellipse = {0})", ellipse.Rectangle);
            }

            // test negative height ellipse
            {
                var ellipse = new EllipsePrimitive();
                ellipse.TopLeft     = new PointF(5, 5);
                ellipse.BottomRight = new PointF(6, -1);
                var roi = ellipse.GetRoi();
                Assert.IsNotNull(roi, "EllipsePrimitive.GetRoi() should never return null (rect = {0})", ellipse.Rectangle);
                AssertAreEqual(new RectangleF(5, -1, 1, 6), roi.BoundingBox, _dimensionTolerance, "EllipsePrimitive.GetRoi() returned wrong ROI (ellipse = {0})", ellipse.Rectangle);
            }
        }
Example #11
0
 private static IGraphic CreateInteractiveEllipse(PointF majorAxisEnd1, PointF majorAxisEnd2, PointF minorAxisEnd1, PointF minorAxisEnd2)
 {
     if (IsAxisAligned(majorAxisEnd1, majorAxisEnd2) && IsAxisAligned(minorAxisEnd1, minorAxisEnd2))
     {
         // use a standard ellipse primitive if the axes defines an axis-aligned ellipse
         var bounds  = RectangleUtilities.ConvertToPositiveRectangle(RectangleUtilities.ComputeBoundingRectangle(majorAxisEnd1, majorAxisEnd2, minorAxisEnd1, minorAxisEnd2));
         var ellipse = new EllipsePrimitive {
             TopLeft = bounds.Location, BottomRight = bounds.Location + bounds.Size
         };
         return(new BoundableResizeControlGraphic(new BoundableStretchControlGraphic(new MoveControlGraphic(ellipse))));
     }
     return(new MoveControlGraphic(CreateEllipse(majorAxisEnd1, majorAxisEnd2, minorAxisEnd1, minorAxisEnd2)));
 }
Example #12
0
        public void TestPointOutside()
        {
            float  a      = -2.5F;
            float  b      = -1.25F;
            PointF center = new PointF(3F, 2F);
            PointF test   = new PointF(13F, 7F);
            PointF result = new PointF(4.767767F, 2.883884F);

            PointF intersection = EllipsePrimitive.IntersectEllipseAndLine(a, b, center, test);

            VerifyPointOnEllipse(a, b, center, intersection);

            Assert.IsTrue(FloatComparer.AreEqual(result, intersection), "ellipse intersection point is not correct!");
        }
Example #13
0
        public void SimpleTest()
        {
            //for a circle of radius=1, test point = 1,1, intesection is 1/sqrt(2), 1/sqrt(2)
            float  a            = 1F;
            float  b            = 1F;
            PointF center       = new PointF(0, 0);
            float  root2Inverse = 1F / (float)Math.Sqrt(2);
            PointF result       = new PointF(root2Inverse, root2Inverse);
            PointF intersection = EllipsePrimitive.IntersectEllipseAndLine(a, b, center, new PointF(1, 1));

            VerifyPointOnEllipse(a, b, center, intersection);

            Assert.IsTrue(FloatComparer.AreEqual(result, intersection), "ellipse intersection point is not correct!");
        }
Example #14
0
        // Token: 0x060041E9 RID: 16873 RVA: 0x0014F210 File Offset: 0x0014D610
        public void GenerateGeometry(float radius, int segments)
        {
            MeshFilter component = base.GetComponent <MeshFilter>();

            if (component.sharedMesh == null)
            {
                component.sharedMesh = new Mesh();
            }
            Mesh sharedMesh = component.sharedMesh;

            base.GenerationTimeMS = EllipsePrimitive.GenerateGeometry(sharedMesh, radius, radius, segments);
            this.radius           = radius;
            this.segments         = segments;
            this.flipNormals      = false;
        }
Example #15
0
        static public GameObject Collider(float radius, int segments)
        {
            var          go    = new GameObject("collider");
            MeshCollider meshc = go.AddComponent(typeof(MeshCollider)) as MeshCollider;

            meshc.sharedMesh = new Mesh();
            var   mesh             = meshc.sharedMesh;
            float GenerationTimeMS = EllipsePrimitive.GenerateGeometry(mesh, radius / 2, radius / 2, segments);

            //go.AddComponent<MeshFilter>().sharedMesh = mesh;
            //go.AddComponent<MeshRenderer>();
            //go.GetComponent<Renderer>().sharedMaterial = new Material(Shader.Find("Diffuse"));

            go.transform.Rotate(-90, 0, 0, Space.Self); //go.transform.Rotate(0, 0, 180, Space.Self); // rotate to standard 2D perspective
            return(go);
        }
        private GeometricShutter ConvertToGeometricShutter()
        {
            GeometricShutter shutter;

            if (_selectedShutterType == ShutterType.Rectangle)
            {
                RectanglePrimitive primitive = (RectanglePrimitive)_primitiveGraphic;
                primitive.CoordinateSystem = CoordinateSystem.Source;
                Rectangle rectangle =
                    new Rectangle((int)primitive.TopLeft.X, (int)primitive.TopLeft.Y, (int)primitive.Width, (int)primitive.Height);
                primitive.ResetCoordinateSystem();

                shutter = new RectangularShutter(rectangle);
            }
            else if (_selectedShutterType == ShutterType.Polygon)
            {
                PolylineGraphic polyLine = (PolylineGraphic)_primitiveGraphic;
                polyLine.CoordinateSystem = CoordinateSystem.Source;

                List <Point> points = new List <Point>();
                for (int i = 0; i < polyLine.Points.Count; ++i)
                {
                    points.Add(new Point((int)polyLine.Points[i].X, (int)polyLine.Points[i].Y));
                }

                polyLine.ResetCoordinateSystem();
                shutter = new PolygonalShutter(points);
            }
            else
            {
                EllipsePrimitive primitive = (EllipsePrimitive)_primitiveGraphic;
                primitive.CoordinateSystem = CoordinateSystem.Source;
                Rectangle rectangle = new Rectangle((int)primitive.TopLeft.X, (int)primitive.TopLeft.Y, (int)primitive.Width, (int)primitive.Height);
                rectangle = RectangleUtilities.ConvertToPositiveRectangle(rectangle);
                int   radius = rectangle.Width / 2;
                Point center = new Point(rectangle.X + radius, rectangle.Y + radius);
                primitive.ResetCoordinateSystem();

                shutter = new CircularShutter(center, radius);
            }

            RemoveDrawShutterGraphic();
            return(shutter);
        }
Example #17
0
        private void ribbonButton49_Click(object sender, EventArgs e)
        {
            if (ellipsePrimitive == null)
            {
                GeoPoint pos = new GeoPoint();
                pos.x   = 116.3;
                pos.y   = 39.9;
                pos.srs = m_earthMap.getSRS();

                Linear radiusMajor = new Linear();
                radiusMajor.set(250, UnitsType.UNIT_MILES);

                Linear radiusMinor = new Linear();
                radiusMinor.set(100, UnitsType.UNIT_MILES);

                Angular rotationAngle = new Angular();
                rotationAngle.set(0, UnitsType.UNIT_DEGREES);

                Angular arcStart = new Angular();
                arcStart.set(45.0, UnitsType.UNIT_DEGREES);

                Angular arcEnd = new Angular();
                arcEnd.set(360.0 - 45.0, UnitsType.UNIT_DEGREES);


                ellipsePrimitive = new EllipsePrimitive();
                ellipsePrimitive.setPosition(pos);
                ellipsePrimitive.setRadiusMajor(radiusMajor);
                ellipsePrimitive.setRadiusMinor(radiusMinor);
                ellipsePrimitive.setRotationAngle(rotationAngle);
                ellipsePrimitive.setArcStart(arcStart);
                ellipsePrimitive.setArcEnd(arcEnd);
                ellipsePrimitive.setPie(true);
                m_earthRoot.addChild(ellipsePrimitive);
            }
        }
Example #18
0
 private void OnCloneComplete()
 {
     _ellipse = CollectionUtils.SelectFirst(base.Graphics, delegate(IGraphic test) { return(test is EllipsePrimitive); }) as EllipsePrimitive;
     Platform.CheckForNullReference(_ellipse, "Cloned Ellipse");
 }
Example #19
0
 /// <summary>
 /// Draws a <see cref="EllipsePrimitive"/>.
 /// </summary>
 protected override void DrawEllipsePrimitive(EllipsePrimitive ellipse)
 {
     DrawEllipsePrimitive(Surface.FinalBuffer, _pen, ellipse, Dpi);
 }
Example #20
0
 private void ribbonButton50_Click(object sender, EventArgs e)
 {
     m_earthRoot.removeChild( ellipsePrimitive );
     ellipsePrimitive = null;
 }
Example #21
0
 private void ribbonButton50_Click(object sender, EventArgs e)
 {
     m_earthRoot.removeChild(ellipsePrimitive);
     ellipsePrimitive = null;
 }
Example #22
0
 protected virtual void DrawEllipsePrimitive(EllipsePrimitive ellipse)
 {
     GdiRenderer.DrawEllipsePrimitive(Surface.OverlayBuffer, _pen, ellipse, Dpi);
 }
Example #23
0
 /// <summary>
 /// Draws a <see cref="EllipsePrimitive"/>.
 /// </summary>
 protected override void DrawEllipsePrimitive(EllipsePrimitive ellipse)
 {
     InternalDrawEllipsePrimitive(ellipse);
 }
Example #24
0
 /// <summary>
 /// Draws a <see cref="EllipsePrimitive"/>.  Must be overridden and implemented.
 /// </summary>
 protected abstract void DrawEllipsePrimitive(EllipsePrimitive ellipse);
Example #25
0
        internal static List <IGraphic> PopulateImageViewerWithSavedMarkup(List <IMarkup> markupList, IImageViewer imageViewer)
        {
            var graphics = new List <IGraphic>();

            foreach (var markup in markupList)
            {
                foreach (var box in imageViewer.PhysicalWorkspace.ImageBoxes)
                {
                    if (box.DisplaySet == null)
                    {
                        continue;
                    }

                    var imageSop =
                        box.DisplaySet.PresentationImages.Cast <IImageSopProvider>().FirstOrDefault(
                            pi => pi.ImageSop.SopInstanceUid == markup.PresentationImageUid && pi.Frame.FrameNumber == markup.FrameNumber);

                    var selectedPresentationImage = imageSop as IPresentationImage;
                    if (selectedPresentationImage == null)
                    {
                        continue;
                    }

                    var graphicsProvider = selectedPresentationImage as IOverlayGraphicsProvider;
                    if (graphicsProvider != null)
                    {
                        if (markup is MarkupEllipse)
                        {
                            var markupEllipse    = (MarkupEllipse)markup;
                            var ellipsePrimitive = new EllipsePrimitive();
                            var roiGraphic       = new RoiGraphic(new BoundableResizeControlGraphic(new BoundableStretchControlGraphic(
                                                                                                        new MoveControlGraphic(ellipsePrimitive))));
                            var boundableGraphic = roiGraphic.Subject as BoundableGraphic;

                            markup.GraphicHashcode = roiGraphic.GetHashCode();
                            graphics.Add(roiGraphic);
                            graphicsProvider.OverlayGraphics.Add(roiGraphic);

                            if (boundableGraphic != null)
                            {
                                roiGraphic.Suspend();                                 // prevent callout location calculation until all points are set
                                roiGraphic.Name = markup.Name;
                                ellipsePrimitive.BottomRight = markupEllipse.BottomRight;
                                ellipsePrimitive.TopLeft     = markupEllipse.TopLeft;
                                roiGraphic.State             = roiGraphic.CreateInactiveState();
                                roiGraphic.Resume(true);                                 // Force callout location calculation
                                roiGraphic.Callout.TextLocation = markupEllipse.CalloutLocation;
                            }
                        }
                        else if (markup is MarkupPolygonal)
                        {
                            var markupPolygon = (MarkupPolygonal)markup;

                            var polyline = new PolylineGraphic(true);
                            foreach (var point in markupPolygon.Vertices)
                            {
                                polyline.Points.Add(point);
                            }
                            var roiGraphic = new RoiGraphic(new PolygonControlGraphic(true, new MoveControlGraphic(polyline)));

                            markup.GraphicHashcode = roiGraphic.GetHashCode();
                            graphics.Add(roiGraphic);
                            graphicsProvider.OverlayGraphics.Add(roiGraphic);

                            //if (boundableGraphic != null)
                            {
                                roiGraphic.Suspend();                                 // prevent callout location calculation until all points are set
                                roiGraphic.Name  = markup.Name;
                                roiGraphic.State = roiGraphic.CreateInactiveState();
                                roiGraphic.Resume(true);                                 // Force callout location calculation
                                roiGraphic.Callout.TextLocation = markupPolygon.CalloutLocation;
                            }
                        }
                        else if (markup is MarkupRectangle)
                        {
                            var markupRectangle    = (MarkupRectangle)markup;
                            var rectanglePrimitive = new RectanglePrimitive();
                            var roiGraphic         = new RoiGraphic(new BoundableResizeControlGraphic(new BoundableStretchControlGraphic(
                                                                                                          new MoveControlGraphic(rectanglePrimitive))));
                            var boundableGraphic = roiGraphic.Subject as BoundableGraphic;

                            markup.GraphicHashcode = roiGraphic.GetHashCode();
                            graphics.Add(roiGraphic);
                            graphicsProvider.OverlayGraphics.Add(roiGraphic);

                            if (boundableGraphic != null)
                            {
                                roiGraphic.Suspend();                                 // prevent callout location calculation until all points are set
                                roiGraphic.Name = markup.Name;
                                rectanglePrimitive.BottomRight = markupRectangle.BottomRight;
                                rectanglePrimitive.TopLeft     = markupRectangle.TopLeft;
                                roiGraphic.State = roiGraphic.CreateInactiveState();
                                roiGraphic.Resume(true);                                 // Force callout location calculation
                                roiGraphic.Callout.TextLocation = markupRectangle.CalloutLocation;
                            }
                        }
                        else if (markup is MarkupProtractor)
                        {
                            var markupProtractor = (MarkupProtractor)markup;

                            var protractorGraphic = new ProtractorGraphic();
                            foreach (var point in markupProtractor.Points)
                            {
                                protractorGraphic.Points.Add(point);
                            }
                            var roiGraphic = new RoiGraphic(new VerticesControlGraphic(new MoveControlGraphic(protractorGraphic)));

                            markup.GraphicHashcode = roiGraphic.GetHashCode();
                            graphics.Add(roiGraphic);
                            graphicsProvider.OverlayGraphics.Add(roiGraphic);

                            roiGraphic.Suspend();                             // prevent callout location calculation until all points are set
                            roiGraphic.Name  = markup.Name;
                            roiGraphic.State = roiGraphic.CreateInactiveState();
                            roiGraphic.Resume(true);                             // Force callout location calculation
                            roiGraphic.Callout.TextLocation = markupProtractor.CalloutLocation;
                        }
                        else if (markup is MarkupLinear)
                        {
                            var markupLinear = (MarkupLinear)markup;

                            var polylineGraphic = new PolylineGraphic();
                            foreach (var point in markupLinear.Vertices)
                            {
                                polylineGraphic.Points.Add(point);
                            }
                            var roiGraphic = new RoiGraphic(new VerticesControlGraphic(new MoveControlGraphic(polylineGraphic)));

                            markup.GraphicHashcode = roiGraphic.GetHashCode();
                            graphics.Add(roiGraphic);
                            graphicsProvider.OverlayGraphics.Add(roiGraphic);

                            roiGraphic.Suspend();                             // prevent callout location calculation until all points are set
                            roiGraphic.Name  = markup.Name;
                            roiGraphic.State = roiGraphic.CreateInactiveState();
                            roiGraphic.Resume(true);                             // Force callout location calculation
                            roiGraphic.Callout.TextLocation = markupLinear.CalloutLocation;
                        }
                        else if (markup is MarkupPoint)
                        {
                            var markupPoint = (MarkupPoint)markup;

                            IGraphic calloutGraphic;
                            if (markupPoint.UseCrosshair)
                            {
                                calloutGraphic = new UserCrosshairCalloutGraphic
                                {
                                    AnchorPoint  = markupPoint.Point,
                                    TextLocation = markupPoint.CalloutLocation,
                                    Text         = markupPoint.CalloutText,
                                    ShowShaft    = !String.IsNullOrEmpty(markupPoint.CalloutText),
                                    LineStyle    = LineStyle.Dot
                                };
                            }
                            else
                            {
                                calloutGraphic = new UserCalloutGraphic
                                {
                                    AnchorPoint   = markupPoint.Point,
                                    TextLocation  = markupPoint.CalloutLocation,
                                    Text          = markupPoint.CalloutText,
                                    ShowArrowhead = true,
                                    LineStyle     = LineStyle.Solid
                                };
                            }

                            var statefulGraphic = new StandardStatefulGraphic(calloutGraphic);
                            statefulGraphic.State = statefulGraphic.CreateInactiveState();

                            var contextGraphic = new ContextMenuControlGraphic(typeof(ClearCanvas.ImageViewer.Tools.Standard.TextCalloutTool).FullName, "basicgraphic-menu", null, statefulGraphic);
                            contextGraphic.Actions = new ToolSet(new GraphicToolExtensionPoint(), new GraphicToolContext(contextGraphic)).Actions;

                            //if (markupPoint.Name != "RemoveForCalloutPlacement")
                            {
                                markup.GraphicHashcode = contextGraphic.GetHashCode();
                                graphics.Add(contextGraphic);
                                graphicsProvider.OverlayGraphics.Add(contextGraphic);
                                //selectedPresentationImage.Draw();
                            }
                        }
                    }

                    box.TopLeftPresentationImage = selectedPresentationImage;
                    box.Tiles[0].Select();
                    box.Draw();

                    break;
                }
            }
            return(graphics);
        }