private void InitializeSceneGraph(
            ImageGraphic imageGraphic,
            double pixelSpacingX,
            double pixelSpacingY,
            double pixelAspectRatioX,
            double pixelAspectRatioY)
        {
            _imageGraphic = imageGraphic;

            _compositeImageGraphic = new CompositeImageGraphic(
                imageGraphic.Rows,
                imageGraphic.Columns,
                pixelSpacingX,
                pixelSpacingY,
                pixelAspectRatioX,
                pixelAspectRatioY);

            _applicationGraphics      = new CompositeGraphic();
            _applicationGraphics.Name = "Application";

            _overlayGraphics      = new CompositeGraphic();
            _overlayGraphics.Name = "Overlay";

            _presentationStateGraphic      = new PresentationStateGraphic();
            _presentationStateGraphic.Name = "PresentationState";

            _compositeImageGraphic.Graphics.Add(_imageGraphic);
            _compositeImageGraphic.Graphics.Add(_applicationGraphics);
            _compositeImageGraphic.Graphics.Add(_overlayGraphics);

            this.SceneGraph.Graphics.Add(_presentationStateGraphic);
            this.SceneGraph.Graphics.Add(_compositeImageGraphic);
        }
Ejemplo n.º 2
0
        //Component


        public void TestComposite()
        {
            // initialize variables
            var compositeGraphic  = new CompositeGraphic();
            var compositeGraphic1 = new CompositeGraphic();
            var compositeGraphic2 = new CompositeGraphic();

            //Add 1 Graphic to compositeGraphic1
            compositeGraphic1.Add(new Ellipse());

            //Add 2 Graphic to compositeGraphic2
            compositeGraphic2.AddRange(new Ellipse(),
                                       new Ellipse());

            /*Add 1 Graphic, compositeGraphic1, and
             * compositeGraphic2 to compositeGraphic */
            compositeGraphic.AddRange(new Ellipse(),
                                      compositeGraphic1,
                                      compositeGraphic2);

            /*Prints the complete graphic
             * (four times the string "Ellipse").*/
            compositeGraphic.Print();
            Console.ReadLine();
        }
Ejemplo n.º 3
0
        private void InitializeSceneGraph(
            int sceneWidth,
            int sceneHeight,
            float dimensionX,
            float dimensionY,
            float dimensionZ,
            float pixelSpacingX,
            float pixelSpacingY,
            float pixelSpacingZ)
        {
            _compositeImageGraphic = new CompositeRootModel3D(sceneWidth, sceneHeight, dimensionX, dimensionY, dimensionZ, pixelSpacingX, pixelSpacingY, pixelSpacingZ)
            {
                Origin = new Vector3D(-dimensionX / 2, -dimensionY / 2, -dimensionZ / 2)
            };

            _applicationGraphics      = new CompositeGraphic();
            _applicationGraphics.Name = "Application2D";

            _overlayGraphics      = new CompositeGraphic();
            _overlayGraphics.Name = "Overlay2D";

            _overlayGraphics3D      = new CompositeGraphic3D();
            _overlayGraphics3D.Name = "Overlay3D";

            _compositeImageGraphic.Graphics.Add(_applicationGraphics);
            _compositeImageGraphic.Graphics.Add(_overlayGraphics);
            _compositeImageGraphic.Graphics3D.Add(_overlayGraphics3D);

            SceneGraph.Graphics.Add(_compositeImageGraphic);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            CompositeGraphic graphic = new CompositeGraphic();


            Ellipse ellipse1 = new Ellipse();
            Ellipse ellipse2 = new Ellipse();
            Ellipse ellipse3 = new Ellipse();
            Ellipse ellipse4 = new Ellipse();

            CompositeGraphic graphic1 = new CompositeGraphic();

            graphic1.AddGraphic(ellipse1);
            graphic1.AddGraphic(ellipse2);
            graphic1.AddGraphic(ellipse3);
            graphic1.AddGraphic(ellipse4);

            CompositeGraphic graphic2 = new CompositeGraphic();

            graphic2.AddGraphic(ellipse1);
            graphic2.AddGraphic(ellipse2);

            graphic.AddGraphic(graphic1);
            graphic.AddGraphic(graphic2);

            //Ако искаме да обходим трябва да имплементираме IEnumerable
            //foreach (var item in graphic)
            //{

            //}
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes the member variables before calling <see cref="Render"/> or <see cref="Refresh"/>.
 /// </summary>
 protected virtual void Initialize(DrawArgs drawArgs)
 {
     _drawMode   = drawArgs.DrawMode;
     _sceneGraph = drawArgs.SceneGraph;
     _surface    = drawArgs.RenderingSurface;
     Dpi         = drawArgs.Dpi;
 }
        private void InstallSnapPointGraphic(bool install)
        {
            IPointsGraphic   subject = this.Graphic;
            CompositeGraphic parent  = subject.ParentGraphic as CompositeGraphic;

            if (parent == null)
            {
                return;
            }

            if (install && subject.Points.Count > 0)
            {
                if (_snapPoint == null)
                {
                    _snapPoint = new SnapPointGraphic();
                }

                if (!parent.Graphics.Contains(_snapPoint))
                {
                    parent.Graphics.Add(_snapPoint);
                }

                _snapPoint.CoordinateSystem = subject.CoordinateSystem;
                _snapPoint.Location         = subject.Points[0];
                _snapPoint.ResetCoordinateSystem();

                parent.Draw();
            }
            else if (_snapPoint != null && parent.Graphics.Contains(_snapPoint))
            {
                parent.Graphics.Remove(_snapPoint);
                parent.Draw();
            }
        }
Ejemplo n.º 7
0
        private void OnCloneComplete()
        {
            _dicomGraphics = CollectionUtils.SelectFirst(base.CompositeImageGraphic.Graphics,
                                                         delegate(IGraphic test) { return(test.Name == "DICOM"); }) as CompositeGraphic;

            Initialize();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Renders the specified scene graph to the graphics surface.
        /// </summary>
        /// <remarks>
        /// Calling code should take care to handle any exceptions in a manner suitable to the context of
        /// the rendering operation. For example, the view control for an
        /// <see cref="ITile"/> may wish to display the error message in the tile's client area <i>without
        /// crashing the control</i>, whereas an image export routine may wish to notify the user via an error
        /// dialog and have the export output <i>fail to be created</i>. Automated routines (such as unit
        /// tests) may even wish that the exception bubble all the way to the top for debugging purposes.
        /// </remarks>
        /// <param name="drawArgs">A <see cref="DrawArgs"/> object that specifies the graphics surface and the scene graph to be rendered.</param>
        /// <exception cref="RenderingException">Thrown if any <see cref="Exception"/> is encountered in the rendering pipeline.</exception>
        public virtual void Draw(DrawArgs drawArgs)
        {
            try
            {
                Initialize(drawArgs);

                if (drawArgs.RenderingSurface.ClientRectangle.Width == 0 || drawArgs.RenderingSurface.ClientRectangle.Height == 0)
                {
                    return;
                }

                if (DrawMode == DrawMode.Render)
                {
                    Render();
                }
                else
                {
                    Refresh();
                }
            }
            catch (Exception e)
            {
                throw new RenderingException(e, drawArgs);
            }
            finally
            {
                _sceneGraph = null;
                _surface    = null;
            }
        }
        public static void Test()
        {
            //Initialize four ellipses
            var ellipse1 = new Ellipse("ellipse1");
            var ellipse2 = new Ellipse("ellipse2");
            var ellipse3 = new Ellipse("ellipse3");
            var ellipse4 = new Ellipse("ellipse4");

            //Initialize three composite graphics
            var graphic  = new CompositeGraphic("graphic");
            var graphic1 = new CompositeGraphic("graphic1");
            var graphic2 = new CompositeGraphic("graphic2");

            //Composes the graphics
            graphic1.Add(ellipse1);
            graphic1.Add(ellipse2);
            graphic1.Add(ellipse3);

            graphic2.Add(ellipse4);

            graphic.Add(graphic1);
            graphic.Add(graphic2);

            //Prints the complete graphic (four times the string "Ellipse").
            graphic.Print();
        }
Ejemplo n.º 10
0
            private void RemoveGraphicFromCurrentImage()
            {
                CompositeGraphic parentGraphic = _crosshairGraphic.ParentGraphic as CompositeGraphic;

                if (parentGraphic != null)
                {
                    parentGraphic.Graphics.Remove(_crosshairGraphic);
                }
            }
        //全选
        private void SelectAll()
        {
            CompositeGraphic mg = compositeGraphic.SelectAll();

            if (mg != null)
            {
                selectedGraphics.Add(mg);
            }
            canvas1.ReleaseMouseCapture();
        }
Ejemplo n.º 12
0
            private void AddGraphicToCurrentImage()
            {
                CompositeGraphic container = _spatialLocatorTool._coordinator.GetSpatialLocatorCompositeGraphic(_presentationImage);

                if (container != null)
                {
                    container.Graphics.Add(_crosshairGraphic);
                    SetGraphicAnchorPoint();
                }
            }
Ejemplo n.º 13
0
        public void TestRotationConstraints()
        {
            SynchronizationContext oldContext = SynchronizationContext.Current;

            if (oldContext == null)
            {
                SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
            }
            try
            {
                CompositeGraphic      sceneGraph     = CreateTestSceneGraph();
                CompositeImageGraphic imageComposite = (CompositeImageGraphic)sceneGraph.Graphics[0];
                ImageGraphic          image          = (ImageGraphic)imageComposite.Graphics[0];
                CompositeGraphic      primitiveOwner = (CompositeGraphic)imageComposite.Graphics[1];
                Graphic primitive = (Graphic)primitiveOwner.Graphics[0];

                RoiGraphic roiGraphic = (RoiGraphic)imageComposite.Graphics[2];

                try
                {
                    sceneGraph.SpatialTransform.RotationXY     = 90;
                    imageComposite.SpatialTransform.RotationXY = 90;
                    primitiveOwner.SpatialTransform.RotationXY = 10;
                    primitive.SpatialTransform.RotationXY      = -20;
                }
                catch (Exception)
                {
                    Assert.Fail("These operations should not throw an exception!");
                }

                Matrix cumulativeTransform;
                try
                {
                    imageComposite.SpatialTransform.RotationXY = 30;
                    //should throw; no non-90 degree rotations allowed on an image
                    cumulativeTransform = image.SpatialTransform.CumulativeTransform;
                    Assert.Fail("expected exception not thrown!");
                }
                catch (ArgumentException)
                {
                    imageComposite.SpatialTransform.RotationXY = 90;
                }

                roiGraphic.SpatialTransform.RotationXY = 100;
                //should throw; no rotation allowed on a roi
                cumulativeTransform = roiGraphic.SpatialTransform.CumulativeTransform;
            }
            finally
            {
                if (oldContext != SynchronizationContext.Current)
                {
                    SynchronizationContext.SetSynchronizationContext(oldContext);
                }
            }
        }
        private void OnCloneComplete()
        {
            _dicomGraphics = CollectionUtils.SelectFirst(base.CompositeImageGraphic.Graphics,
                                                         delegate(IGraphic test) { return(test.Name == "DICOM"); }) as CompositeGraphic;

            if (AnnotationLayout is MammogramAnnotationLayoutProxy)
            {
                ((MammogramAnnotationLayoutProxy)AnnotationLayout).OwnerImage = this;
            }

            Initialize();
        }
Ejemplo n.º 15
0
        private void OnCloneComplete()
        {
            _fusionOverlayLayer = (CompositeGraphic)CollectionUtils.SelectFirst(base.CompositeImageGraphic.Graphics,
                                                                                g => g is CompositeGraphic && g.Name == _fusionOverlayLayerName);

            if (_fusionOverlayLayer != null)
            {
                _fusionOverlayComposite = (FusionOverlayCompositeGraphic)CollectionUtils.SelectFirst(_fusionOverlayLayer.Graphics, g => g is FusionOverlayCompositeGraphic);
            }

            Initialize();
        }
Ejemplo n.º 16
0
        static void Main(string[] args)
        {
            var compositeGraphic = new CompositeGraphic();

            compositeGraphic.Add(new Ellipse());
            compositeGraphic.Add(new Rectangle());

            var anotherCompositeGraphic = new CompositeGraphic();

            anotherCompositeGraphic.Add(new Ellipse());
            anotherCompositeGraphic.Add(compositeGraphic);

            anotherCompositeGraphic.Draw();
        }
Ejemplo n.º 17
0
        private void OnCloneComplete()
        {
            _compositeImageGraphic = (CompositeRootModel3D)CollectionUtils.SelectFirst(SceneGraph.Graphics, test => test is CompositeRootModel3D);

            Platform.CheckForNullReference(_compositeImageGraphic, "_compositeImageGraphic");

            _applicationGraphics = (CompositeGraphic)CollectionUtils.SelectFirst(_compositeImageGraphic.Graphics, test => test.Name == "Application2D");
            _overlayGraphics     = (CompositeGraphic)CollectionUtils.SelectFirst(_compositeImageGraphic.Graphics, test => test.Name == "Overlay2D");
            _overlayGraphics3D   = (CompositeGraphic3D)CollectionUtils.SelectFirst(_compositeImageGraphic.Graphics3D, test => test.Name == "Overlay3D");

            Platform.CheckForNullReference(_applicationGraphics, "_applicationGraphics");
            Platform.CheckForNullReference(_overlayGraphics, "_overlayGraphics");
            Platform.CheckForNullReference(_overlayGraphics3D, "_overlayGraphics3D");
        }
Ejemplo n.º 18
0
        private static void SetTransformValidationPolicy(CompositeGraphic compositeGraphic)
        {
            foreach (IGraphic graphic in compositeGraphic.Graphics)
            {
                if (graphic is CompositeGraphic)
                {
                    SetTransformValidationPolicy(graphic as CompositeGraphic);
                }

                if (!(compositeGraphic.SpatialTransform.ValidationPolicy is RoiTransformPolicy))
                {
                    compositeGraphic.SpatialTransform.ValidationPolicy = new RoiTransformPolicy();
                }
            }
        }
Ejemplo n.º 19
0
        private IMouseButtonHandler FindHandlingGraphic(CallHandlerMethodDelegate handlerDelegate)
        {
            if (_tile.PresentationImage is PresentationImage)
            {
                CompositeGraphic sceneGraph = ((PresentationImage)_tile.PresentationImage).SceneGraph;
                foreach (IMouseButtonHandler handler in GetHandlerGraphics(sceneGraph))
                {
                    if (handlerDelegate(handler))
                    {
                        return(handler);
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 20
0
        private bool StartNewGraphicHandler()
        {
            if (_tile.PresentationImage is PresentationImage)
            {
                CompositeGraphic sceneGraph = ((PresentationImage)_tile.PresentationImage).SceneGraph;
                foreach (IMouseButtonHandler handler in GetHandlerGraphics(sceneGraph))
                {
                    if (CanStartNewHandler(handler) && StartHandler(handler))
                    {
                        SetCapture(handler);
                        return(true);
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Implementation of the <see cref="IDisposable"/> pattern
        /// </summary>
        /// <param name="disposing">True if this object is being disposed, false if it is being finalized</param>
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_renderer != null)
                {
                    _renderer.Dispose();
                    _renderer = null;
                }

                if (_sceneGraph != null)
                {
                    _sceneGraph.Dispose();
                    _sceneGraph = null;
                }
            }
        }
        private void Initialize()
        {
            if (base.ImageGraphic.VoiLutFactory == null)
            {
                base.ImageGraphic.VoiLutFactory = GraphicVoiLutFactory.Create(GetInitialVoiLut);
            }

            if (_dicomGraphics == null)
            {
                _dicomGraphics      = new CompositeGraphic();
                _dicomGraphics.Name = "DICOM";

                // insert the DICOM graphics layer right after the image graphic (both contain domain-level graphics)
                IGraphic imageGraphic = CollectionUtils.SelectFirst(base.CompositeImageGraphic.Graphics, g => g is ImageGraphic);
                base.CompositeImageGraphic.Graphics.Insert(base.CompositeImageGraphic.Graphics.IndexOf(imageGraphic) + 1, _dicomGraphics);
            }
        }
Ejemplo n.º 23
0
 private IEnumerable <IMouseButtonHandler> GetHandlerGraphics(CompositeGraphic compositeGraphic)
 {
     foreach (IGraphic graphic in GetVisibleGraphics(compositeGraphic))
     {
         if (graphic is IMouseButtonHandler)
         {
             yield return(graphic as IMouseButtonHandler);
         }
         else if (graphic is CompositeGraphic)
         {
             foreach (IMouseButtonHandler handler in GetHandlerGraphics(graphic as CompositeGraphic))
             {
                 yield return(handler);
             }
         }
     }
 }
Ejemplo n.º 24
0
        private void Initialize()
        {
            if (_fusionOverlayLayer == null)
            {
                _fusionOverlayLayer = new CompositeGraphic {
                    Name = _fusionOverlayLayerName
                };

                // insert the fusion graphics layer right after the base image graphic (both contain domain-level graphics)
                base.CompositeImageGraphic.Graphics.Insert(base.CompositeImageGraphic.Graphics.IndexOf(this.ImageGraphic) + 1, _fusionOverlayLayer);
            }

            if (_fusionOverlayComposite == null)
            {
                _fusionOverlayComposite = new FusionOverlayCompositeGraphic(_overlayFrameDataReference.FusionOverlayFrameData);
                _fusionOverlayLayer.Graphics.Add(_fusionOverlayComposite);
            }
        }
Ejemplo n.º 25
0
        private void ProcessExplicitContextMenuRequest(Point?location, ActionModelNode actionModel)
        {
            //Force a handler with capture to release.
            if (this.CaptureHandler != null)
            {
                ReleaseCapture(true);
            }

            //When we show the context menu, reset the active button and start count,
            //because the user is going to have to start over again with a new click.
            _activeButton = 0;
            _startCount   = 0;

            if (!location.HasValue || !TileClientRectangle.Contains(location.Value))
            {
                location = _currentMousePoint;
            }

            if (actionModel == null)
            {
                CompositeGraphic sceneGraph = ((PresentationImage)_tile.PresentationImage).SceneGraph;
                //Get all the mouse button handlers that provide a context menu.
                foreach (var handlerGraphic in GetHandlerGraphics(sceneGraph).OfType <IContextMenuProvider>())
                {
                    var actionSet = handlerGraphic.GetContextMenuModel(this);
                    if (actionSet != null && actionSet.ChildNodes.Count > 0)
                    {
                        ContextMenuProvider = handlerGraphic;
                        break;
                    }
                }
            }
            else
            {
                ContextMenuProvider = new ActionModelProvider(actionModel);
            }

            //Request the context menu.
            _contextMenuEnabled = true;
            EventsHelper.Fire(_contextMenuRequested, this, new ItemEventArgs <Point>(location.Value));

            ContextMenuProvider = null;
        }
Ejemplo n.º 26
0
        private static CompositeGraphic CreateTestSceneGraph()
        {
            CompositeGraphic      sceneGraph     = new CompositeGraphic();
            ImageSpatialTransform imageTransform = CreateTransform();

            sceneGraph.Graphics.Add(imageTransform.OwnerGraphic);

            CompositeGraphic composite = new CompositeGraphic();
            Graphic          leaf      = new LinePrimitive();

            composite.Graphics.Add(leaf);
            ((CompositeImageGraphic)imageTransform.OwnerGraphic).Graphics.Add(composite);

            RoiGraphic roiGraphic = new RoiGraphic(new EllipsePrimitive());

            ((CompositeImageGraphic)imageTransform.OwnerGraphic).Graphics.Add(roiGraphic);

            return(sceneGraph);
        }
Ejemplo n.º 27
0
        public void CumulativeScale()
        {
            CompositeGraphic sceneGraph = new CompositeGraphic();

            CompositeGraphic graphic1 = new CompositeGraphic();

            graphic1.SpatialTransform.Scale = 2.0f;
            Assert.AreEqual(graphic1.SpatialTransform.CumulativeScale, 2.0f);
            Assert.AreEqual(graphic1.SpatialTransform.CumulativeTransform.Elements[0], 2.0f);

            CompositeGraphic graphic2 = new CompositeGraphic();

            graphic2.SpatialTransform.Scale = 3.0f;
            Assert.AreEqual(graphic2.SpatialTransform.CumulativeScale, 3.0f);
            Assert.AreEqual(graphic2.SpatialTransform.CumulativeTransform.Elements[0], 3.0f);

            CompositeGraphic graphic3 = new CompositeGraphic();

            graphic3.SpatialTransform.Scale = 4.0f;
            Assert.AreEqual(graphic3.SpatialTransform.CumulativeScale, 4.0f);
            Assert.AreEqual(graphic3.SpatialTransform.CumulativeTransform.Elements[0], 4.0f);

            graphic1.Graphics.Add(graphic2);
            Assert.AreEqual(graphic1.SpatialTransform.CumulativeScale, 2.0f);
            Assert.AreEqual(graphic1.SpatialTransform.CumulativeTransform.Elements[0], 2.0f);
            Assert.AreEqual(graphic2.SpatialTransform.CumulativeScale, 6.0f);
            Assert.AreEqual(graphic2.SpatialTransform.CumulativeTransform.Elements[0], 6.0f);

            graphic2.Graphics.Add(graphic3);
            Assert.AreEqual(graphic2.SpatialTransform.CumulativeScale, 6.0f);
            Assert.AreEqual(graphic2.SpatialTransform.CumulativeTransform.Elements[0], 6.0f);
            Assert.AreEqual(graphic3.SpatialTransform.CumulativeScale, 24.0f);
            Assert.AreEqual(graphic3.SpatialTransform.CumulativeTransform.Elements[0], 24.0f);

            sceneGraph.Graphics.Add(graphic1);
            Assert.AreEqual(graphic1.SpatialTransform.CumulativeScale, 2.0f);
            Assert.AreEqual(graphic1.SpatialTransform.CumulativeTransform.Elements[0], 2.0f);
            Assert.AreEqual(graphic2.SpatialTransform.CumulativeScale, 6.0f);
            Assert.AreEqual(graphic2.SpatialTransform.CumulativeTransform.Elements[0], 6.0f);
            Assert.AreEqual(graphic3.SpatialTransform.CumulativeScale, 24.0f);
            Assert.AreEqual(graphic3.SpatialTransform.CumulativeTransform.Elements[0], 24.0f);
        }
Ejemplo n.º 28
0
        private void Initialize()
        {
            base.VoiLutsEnabled = DicomPresentationImageSettings.Default.AllowWindowingOnColorImages;

            if (base.ImageGraphic.VoiLutFactory == null)
            {
                base.ImageGraphic.VoiLutFactory = GraphicVoiLutFactory.Create(
                    graphic => InitialVoiLutProvider.Instance.GetLut(graphic.ParentPresentationImage));
            }

            if (_dicomGraphics == null)
            {
                _dicomGraphics      = new CompositeGraphic();
                _dicomGraphics.Name = "DICOM";

                // insert the DICOM graphics layer right after the image graphic (both contain domain-level graphics)
                IGraphic imageGraphic = CollectionUtils.SelectFirst(base.CompositeImageGraphic.Graphics, g => g is ImageGraphic);
                base.CompositeImageGraphic.Graphics.Insert(base.CompositeImageGraphic.Graphics.IndexOf(imageGraphic) + 1, _dicomGraphics);
            }
        }
Ejemplo n.º 29
0
    static void Main(string[] args)
    {
        // Initialize variables
        var compositeGraphic1 = new CompositeGraphic();
        var compositeGraphic2 = new CompositeGraphic();
        var compositeGraphic3 = new CompositeGraphic();

        // Add 1 Graphic to compositeGraphic2
        compositeGraphic2.Add(new Ellipse());

        // Add 2 Graphic to compositeGraphic3
        compositeGraphic3.AddRange(new Ellipse(), new Circle());

        // Add 1 Graphic, compositeGraphic2, and  compositeGraphic3 to compositeGraphic1
        compositeGraphic1.AddRange(new Circle(), compositeGraphic2, compositeGraphic3);

        // Print the complete graphic
        compositeGraphic1.Print();

        Console.ReadKey();
    }
Ejemplo n.º 30
0
    static void Main(string[] args)
    {
        // Initialize variables
        var compositeGraphic1 = new CompositeGraphic();
        var compositeGraphic2 = new CompositeGraphic();
        var compositeGraphic3 = new CompositeGraphic();

        // Add 1 Graphic to compositeGraphic2
        compositeGraphic2.Add(new Ellipse());

        // Add 2 Graphic to compositeGraphic3
        compositeGraphic3.AddRange(new Ellipse(), new Circle());

        // Add 1 Graphic, compositeGraphic2, and  compositeGraphic3 to compositeGraphic1
        compositeGraphic1.AddRange(new Circle(), compositeGraphic2, compositeGraphic3);

        // Print the complete graphic
        compositeGraphic1.Print();

        Console.ReadKey();
    }
Ejemplo n.º 31
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                _fusionOverlayLayer     = null;
                _fusionOverlayComposite = null;

                if (_baseFrameReference != null)
                {
                    _baseFrameReference.Dispose();
                    _baseFrameReference = null;
                }

                if (_overlayFrameDataReference != null)
                {
                    _overlayFrameDataReference.Dispose();
                    _overlayFrameDataReference = null;
                }
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 32
0
		public void CumulativeRotation()
		{
			CompositeGraphic sceneGraph = new CompositeGraphic();
			CompositeGraphic graphic1 = new CompositeGraphic();
			CompositeGraphic graphic2 = new CompositeGraphic();
			CompositeGraphic graphic3 = new CompositeGraphic();

			sceneGraph.Graphics.Add(graphic1);
			graphic1.Graphics.Add(graphic2);
			graphic1.Graphics.Add(graphic3);

			sceneGraph.SpatialTransform.RotationXY = 90;
			graphic1.SpatialTransform.RotationXY = 90;
			graphic2.SpatialTransform.RotationXY = 100;
			graphic3.SpatialTransform.RotationXY = -270;

			//90
			Assert.AreEqual(sceneGraph.SpatialTransform.Transform.Elements[0], 0, 0.0001F);
			Assert.AreEqual(sceneGraph.SpatialTransform.Transform.Elements[1], 1, 0.0001F);
			Assert.AreEqual(sceneGraph.SpatialTransform.Transform.Elements[2], -1, 0.0001F);
			Assert.AreEqual(sceneGraph.SpatialTransform.Transform.Elements[3], 0, 0.0001F);

			//90 + 90
			Assert.AreEqual(graphic1.SpatialTransform.Transform.Elements[0], 0, 0.0001F);
			Assert.AreEqual(graphic1.SpatialTransform.Transform.Elements[1], 1, 0.0001F);
			Assert.AreEqual(graphic1.SpatialTransform.Transform.Elements[2], -1, 0.0001F);
			Assert.AreEqual(graphic1.SpatialTransform.Transform.Elements[3], 0, 0.0001F);
			Assert.AreEqual(graphic1.SpatialTransform.CumulativeTransform.Elements[0], -1, 0.0001F);
			Assert.AreEqual(graphic1.SpatialTransform.CumulativeTransform.Elements[1], 0, 0.0001F);
			Assert.AreEqual(graphic1.SpatialTransform.CumulativeTransform.Elements[2], 0, 0.0001F);
			Assert.AreEqual(graphic1.SpatialTransform.CumulativeTransform.Elements[3], -1, 0.0001F);

			//90 + 90 - 270 (+ 360)
			Assert.AreEqual(graphic3.SpatialTransform.Transform.Elements[0], 0, 0.0001F);
			Assert.AreEqual(graphic3.SpatialTransform.Transform.Elements[1], 1, 0.0001F);
			Assert.AreEqual(graphic3.SpatialTransform.Transform.Elements[2], -1, 0.0001F);
			Assert.AreEqual(graphic3.SpatialTransform.Transform.Elements[3], 0, 0.0001F);
			Assert.AreEqual(graphic3.SpatialTransform.CumulativeTransform.Elements[0], 0, 0.0001F);
			Assert.AreEqual(graphic3.SpatialTransform.CumulativeTransform.Elements[1], -1, 0.0001F);
			Assert.AreEqual(graphic3.SpatialTransform.CumulativeTransform.Elements[2], 1, 0.0001F);
			Assert.AreEqual(graphic3.SpatialTransform.CumulativeTransform.Elements[3], 0, 0.0001F);

			//90 + 90 + 100
			Assert.AreEqual(graphic2.SpatialTransform.Transform.Elements[0], -0.1736, 0.0001F);
			Assert.AreEqual(graphic2.SpatialTransform.Transform.Elements[1], 0.9848, 0.0001F);
			Assert.AreEqual(graphic2.SpatialTransform.Transform.Elements[2], -0.9848, 0.0001F);
			Assert.AreEqual(graphic2.SpatialTransform.Transform.Elements[3], -0.1736, 0.0001F);
			Assert.AreEqual(graphic2.SpatialTransform.CumulativeTransform.Elements[0], 0.1736, 0.0001F);
			Assert.AreEqual(graphic2.SpatialTransform.CumulativeTransform.Elements[1], -0.9848, 0.0001F);
			Assert.AreEqual(graphic2.SpatialTransform.CumulativeTransform.Elements[2], 0.9848, 0.0001F);
			Assert.AreEqual(graphic2.SpatialTransform.CumulativeTransform.Elements[3], 0.1736, 0.0001F);

			graphic2.SpatialTransform.FlipX = true;
			Assert.AreEqual(graphic2.SpatialTransform.Transform.Elements[0], -0.1736, 0.0001F);
			Assert.AreEqual(graphic2.SpatialTransform.Transform.Elements[1], 0.9848, 0.0001F);
			Assert.AreEqual(graphic2.SpatialTransform.Transform.Elements[2], 0.9848, 0.0001F);
			Assert.AreEqual(graphic2.SpatialTransform.Transform.Elements[3], 0.1736, 0.0001F);
			Assert.AreEqual(graphic2.SpatialTransform.CumulativeTransform.Elements[0], 0.1736, 0.0001F);
			Assert.AreEqual(graphic2.SpatialTransform.CumulativeTransform.Elements[1], -0.9848, 0.0001F);
			Assert.AreEqual(graphic2.SpatialTransform.CumulativeTransform.Elements[2], -0.9848, 0.0001F);
			Assert.AreEqual(graphic2.SpatialTransform.CumulativeTransform.Elements[3], -0.1736, 0.0001F);

			graphic2.SpatialTransform.FlipY = true;
			Assert.AreEqual(graphic2.SpatialTransform.Transform.Elements[0], 0.1736, 0.0001F);
			Assert.AreEqual(graphic2.SpatialTransform.Transform.Elements[1], -0.9848, 0.0001F);
			Assert.AreEqual(graphic2.SpatialTransform.Transform.Elements[2], 0.9848, 0.0001F);
			Assert.AreEqual(graphic2.SpatialTransform.Transform.Elements[3], 0.1736, 0.0001F);
			Assert.AreEqual(graphic2.SpatialTransform.CumulativeTransform.Elements[0], -0.1736, 0.0001F);
			Assert.AreEqual(graphic2.SpatialTransform.CumulativeTransform.Elements[1], 0.9848, 0.0001F);
			Assert.AreEqual(graphic2.SpatialTransform.CumulativeTransform.Elements[2], -0.9848, 0.0001F);
			Assert.AreEqual(graphic2.SpatialTransform.CumulativeTransform.Elements[3], -0.1736, 0.0001F);
		}
Ejemplo n.º 33
0
		public void CumulativeScale()
		{
			CompositeGraphic sceneGraph = new CompositeGraphic();

			CompositeGraphic graphic1 = new CompositeGraphic();
			graphic1.SpatialTransform.Scale = 2.0f;
			Assert.AreEqual(graphic1.SpatialTransform.CumulativeScale, 2.0f);
			Assert.AreEqual(graphic1.SpatialTransform.CumulativeTransform.Elements[0], 2.0f);

			CompositeGraphic graphic2 = new CompositeGraphic();
			graphic2.SpatialTransform.Scale = 3.0f;
			Assert.AreEqual(graphic2.SpatialTransform.CumulativeScale, 3.0f);
			Assert.AreEqual(graphic2.SpatialTransform.CumulativeTransform.Elements[0], 3.0f);
			
			CompositeGraphic graphic3 = new CompositeGraphic();
			graphic3.SpatialTransform.Scale = 4.0f;
			Assert.AreEqual(graphic3.SpatialTransform.CumulativeScale, 4.0f);
			Assert.AreEqual(graphic3.SpatialTransform.CumulativeTransform.Elements[0], 4.0f);

			graphic1.Graphics.Add(graphic2);
			Assert.AreEqual(graphic1.SpatialTransform.CumulativeScale, 2.0f);
			Assert.AreEqual(graphic1.SpatialTransform.CumulativeTransform.Elements[0], 2.0f);
			Assert.AreEqual(graphic2.SpatialTransform.CumulativeScale, 6.0f);
			Assert.AreEqual(graphic2.SpatialTransform.CumulativeTransform.Elements[0], 6.0f);

			graphic2.Graphics.Add(graphic3);
			Assert.AreEqual(graphic2.SpatialTransform.CumulativeScale, 6.0f);
			Assert.AreEqual(graphic2.SpatialTransform.CumulativeTransform.Elements[0], 6.0f);
			Assert.AreEqual(graphic3.SpatialTransform.CumulativeScale, 24.0f);
			Assert.AreEqual(graphic3.SpatialTransform.CumulativeTransform.Elements[0], 24.0f);

			sceneGraph.Graphics.Add(graphic1);
			Assert.AreEqual(graphic1.SpatialTransform.CumulativeScale, 2.0f);
			Assert.AreEqual(graphic1.SpatialTransform.CumulativeTransform.Elements[0], 2.0f);
			Assert.AreEqual(graphic2.SpatialTransform.CumulativeScale, 6.0f);
			Assert.AreEqual(graphic2.SpatialTransform.CumulativeTransform.Elements[0], 6.0f);
			Assert.AreEqual(graphic3.SpatialTransform.CumulativeScale, 24.0f);
			Assert.AreEqual(graphic3.SpatialTransform.CumulativeTransform.Elements[0], 24.0f);
		}