private void OnCloneComplete()
		{
			_dicomGraphics = CollectionUtils.SelectFirst(base.CompositeImageGraphic.Graphics,
				delegate(IGraphic test) { return test.Name == "DICOM"; }) as CompositeGraphic;

			Initialize();
		}
Beispiel #2
0
        private void Validate()
        {
            CompositeGraphic parentGraphic = _graphic.ParentGraphic as CompositeGraphic;

            if (parentGraphic == null)
            {
                throw new InvalidOperationException("The graphic must have a parent.");
            }
        }
Beispiel #3
0
 private void Initialize(CompositeGraphic source, ICloningContext context)
 {
     foreach (IGraphic graphic in source.Graphics)
     {
         IGraphic clone = graphic.Clone();
         if (clone != null)
         {
             this.Graphics.Add(clone);
         }
     }
 }
Beispiel #4
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();
		}
Beispiel #5
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);
			}
		}
Beispiel #6
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();
			}
		}
Beispiel #7
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;
			}
		}
Beispiel #8
0
		/// <summary>
		/// Traverses and Renders the Scene Graph.
		/// </summary>
		protected void DrawSceneGraph(CompositeGraphic sceneGraph)
		{
			foreach (Graphic graphic in sceneGraph.Graphics)
			{
				if (graphic.Visible)
				{
					graphic.OnDrawing();

					if (graphic is CompositeGraphic)
						DrawSceneGraph((CompositeGraphic)graphic);
					else if (graphic is ImageGraphic)
						DrawImageGraphic((ImageGraphic)graphic);
					else if (graphic is LinePrimitive)
						DrawLinePrimitive((LinePrimitive)graphic);
					else if (graphic is InvariantLinePrimitive)
						DrawInvariantLinePrimitive((InvariantLinePrimitive)graphic);
					else if (graphic is CurvePrimitive)
						DrawCurvePrimitive((CurvePrimitive)graphic);
					else if (graphic is RectanglePrimitive)
						DrawRectanglePrimitive((RectanglePrimitive)graphic);
					else if (graphic is InvariantRectanglePrimitive)
						DrawInvariantRectanglePrimitive((InvariantRectanglePrimitive)graphic);
					else if (graphic is EllipsePrimitive)
						DrawEllipsePrimitive((EllipsePrimitive)graphic);
					else if (graphic is InvariantEllipsePrimitive)
						DrawInvariantEllipsePrimitive((InvariantEllipsePrimitive)graphic);
					else if (graphic is ArcPrimitive)
						DrawArcPrimitive((IArcGraphic)graphic);
					else if (graphic is InvariantArcPrimitive)
						DrawArcPrimitive((IArcGraphic)graphic);
					else if (graphic is PointPrimitive)
						DrawPointPrimitive((PointPrimitive)graphic);
					else if (graphic is InvariantTextPrimitive)
						DrawTextPrimitive((InvariantTextPrimitive)graphic);
				}
			}
		}
Beispiel #9
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 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);
			}
		}
		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");
		}
Beispiel #12
0
		private IEnumerable<IGraphic> GetVisibleGraphics(CompositeGraphic compositeGraphic)
		{
		    return compositeGraphic.EnumerateChildGraphics(true).Where(g => g.Visible);
		}
Beispiel #13
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;
				}

				if (_extensionData != null)
				{
					_extensionData.Dispose();
					_extensionData = null;
				}
			}
		}
Beispiel #14
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);
		}
		private void Initialize(CompositeGraphic source, ICloningContext context)
		{
			foreach (IGraphic graphic in source.Graphics)
			{
				IGraphic clone = graphic.Clone();
				if (clone != null)
					this.Graphics.Add(clone);
			}
		}
		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);
			}
		}
		private void OnCloneComplete()
		{
			_dicomGraphics = CollectionUtils.SelectFirst(base.CompositeImageGraphic.Graphics,
			                                             test => test.Name == "DICOM") as CompositeGraphic;

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

			Initialize();
		}
Beispiel #18
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;
				}
			}
		}
		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);
		}