C#
VB
C++
Represents the cell that will be used to display the panoramic frame resulted from adding a MedicalViewerMPRPolygon to a another cell.
public class MedicalViewerPanoramicCell : MedicalViewerCell Public Class MedicalViewerPanoramicCellInherits Leadtools.Medicalviewer.MedicalViewerCellImplements Leadtools.Annotations.Core.Leadtools.Annotations.Core.IAnnAutomationControl, System.ComponentModel.IComponent, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.ISynchronizeInvoke, System.IDisposable, System.Windows.Forms.IBindableComponent, System.Windows.Forms.IDropTarget, System.Windows.Forms.IWin32Window
public ref class MedicalViewerPanoramicCell : public Leadtools.Medicalviewer.MedicalViewerCell, Leadtools.Annotations.Core.Leadtools.Annotations.Core.IAnnAutomationControl, System.ComponentModel.IComponent, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.ISynchronizeInvoke, System.IDisposable, System.Windows.Forms.IBindableComponent, System.Windows.Forms.IDropTarget, System.Windows.Forms.IWin32Window
In order to connect this panoramic cell to a polygon, pass it to the Polygon. The user cannot draw the MedicalViewerMPRPolygon to:
using Leadtools;using Leadtools.Dicom;using Leadtools.Medical3D;using Leadtools.Codecs;using Leadtools.MedicalViewer;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Core;using Leadtools.ImageProcessing.Color;using Leadtools.Annotations.Core;using Leadtools.Annotations.Designers;class MedicalViewerMPRPolygonForm : Form{private MedicalViewer _medicalViewer;private MedicalViewerSeriesManager _seriesManager;void MedicalViewerLocalizer_SizeChanged(object sender, EventArgs e){_medicalViewer.Size = new Size(this.ClientRectangle.Right, this.ClientRectangle.Bottom);}public MedicalViewerMPRPolygonForm(MedicalViewerSeriesManager output){DicomEngine.Startup();RasterCodecs _codecs = new RasterCodecs();this.SizeChanged += new EventHandler(MedicalViewerLocalizer_SizeChanged);// Create the medical viewer and adjust the size and the location._medicalViewer = new MedicalViewer(1, 2);_medicalViewer.Location = new Point(0, 0);_medicalViewer.Size = new Size(this.ClientRectangle.Right, this.ClientRectangle.Bottom);_seriesManager = output;MedicalViewerMultiCell cell = new MedicalViewerMultiCell(null, true, 1, 1);int index;int count = output.Stacks[0].Items.Count;CodecsImageInfo codecsInformation;MedicalViewerImageInformation[] imageInformation = new MedicalViewerImageInformation[count];for (index = 0; index < count; index++){codecsInformation = _codecs.GetInformation((string)(output.Stacks[0].Items[index].Data), true);imageInformation[index] = new MedicalViewerImageInformation();imageInformation[index].ImageHeight = codecsInformation.Width;imageInformation[index].ImageWidth = codecsInformation.Width;imageInformation[index].XResolution = codecsInformation.XResolution;imageInformation[index].YResolution = codecsInformation.YResolution;}cell.FramesRequested += new EventHandler<MedicalViewerRequestedFramesInformationEventArgs>(cell_FramesRequested);FormClosing += new FormClosingEventHandler(MedicalViewerLocalizer_FormClosing);cell.EnableLowMemoryUsage(2, count, imageInformation);_medicalViewer.Cells.Add(cell);// add some actions that will be used to change the properties of the images inside the control.cell.AddAction(MedicalViewerActionType.WindowLevel);cell.AddAction(MedicalViewerActionType.Alpha);cell.AddAction(MedicalViewerActionType.Offset);// assign the added actions to a mouse button, meaning that when the user clicks and drags the mouse button, the associated action will be activated.cell.SetAction(MedicalViewerActionType.WindowLevel, MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active);cell.SetAction(MedicalViewerActionType.Alpha, MedicalViewerMouseButtons.Middle, MedicalViewerActionFlags.Active);cell.SetAction(MedicalViewerActionType.Offset, MedicalViewerMouseButtons.Right, MedicalViewerActionFlags.Active);cell.ReferenceLine.Enabled = true;cell.ReferenceLine.Color = Color.Yellow;cell.ShowCellBoundaries = true;// adjust some properties of the cell and add some tags._medicalViewer.Cells[0].SetTag(2, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.UserData, "EX. ID 230-36-5448");_medicalViewer.Cells[0].SetTag(4, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame);_medicalViewer.Cells[0].SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Scale);_medicalViewer.Cells[0].SetTag(2, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.WindowLevelData);_medicalViewer.Cells[0].SetTag(1, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.FieldOfView);cell.PixelSpacing = output.Stacks[0].PixelSpacing;for (index = 0; index < count; index++){cell.SetImagePosition(index, output.Stacks[0].Items[index].ImagePosition, (index == count - 1));}cell.ImageOrientation = output.Stacks[0].Items[0].ImageOrientationArray;cell.FrameOfReferenceUID = output.Stacks[0].Items[0].FrameOfReferenceUID;int width = cell.VirtualImage[cell.ActiveSubCell].Image.Width;int height = cell.VirtualImage[cell.ActiveSubCell].Image.Height;Controls.Add(_medicalViewer);_medicalViewer.Dock = DockStyle.Fill;DicomEngine.Shutdown();// create a new polygonMedicalViewerMPRPolygon polygon = new MedicalViewerMPRPolygon();// set some point, here we created a polygon that resembles a rectangle with a missing bottom line.polygon.Points.Add(new PointF(width * 1 / 4, height * 3 / 4));polygon.Points.Add(new PointF(width * 1 / 4, height * 1 / 4));polygon.Points.Add(new PointF(width * 3 / 4, height * 1 / 4));polygon.Points.Add(new PointF(width * 3 / 4, height * 3 / 4));// now add this polygon you prepared to the cell.cell.Polygons.Add(polygon);// This event is important, because it's used to request the data that is need to create the internal panoramic data.cell.PanoramicDataRequested += new EventHandler<MedicalViewerPanoramicDataRequestedEventArgs>(cell_PanoramicDataRequested);// This event communicate with the Medical3D dll which contains all the internal panormaic calculations.cell.Data3DRequested += new EventHandler<MedicalViewerData3DRequestedEventArgs>(cell_Data3DRequested);// Dispose the internal data automatically if the use decided to delete the polygon.cell.AutoDisposeInternalData = true;// register the polygon clickcell.MPRPolygonClicked += new EventHandler<MedicalViewerMPRPolygonClickedEventsArgs>(cell_MPRPolygonClicked);CreatePanoramicCell(cell, polygon);polygon.Recalculate();}void cell_Data3DRequested(object sender, MedicalViewerData3DRequestedEventArgs e){e.Succeed = Medical3DEngine.Provide3DInformation(e);}void CreatePanoramicCell(MedicalViewerMultiCell cellSource, MedicalViewerMPRPolygon polygon){// create a new panoramic cell assigned to the polygon you created.MedicalViewerPanoramicCell cell = new MedicalViewerPanoramicCell(polygon);// add some action, not necessary though.cell.AddAction(MedicalViewerActionType.WindowLevel);cell.AddAction(MedicalViewerActionType.Scale);cell.AddAction(MedicalViewerActionType.Offset);cell.AddAction(MedicalViewerActionType.Stack);cell.SetAction(MedicalViewerActionType.Offset, MedicalViewerMouseButtons.Right, MedicalViewerActionFlags.AllCells | MedicalViewerActionFlags.RealTime);cell.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active);cell.SetAction(MedicalViewerActionType.Scale, MedicalViewerMouseButtons.Middle, MedicalViewerActionFlags.Active);// Add the panoramic cell the viewer._medicalViewer.Cells.Add(cell);// Create a paraxial cell, and assign it to the polygon you just created.MedicalViewerParaxialCutCell paraxialCell = new MedicalViewerParaxialCutCell (polygon, 0);// set the distance and the length of the paraxial cuts.paraxialCell.ParaxialDistance = 20;paraxialCell.ParaxialLength = 200;// Add the paraxial cuts to the viewer._medicalViewer.Cells.Add(paraxialCell);}void cell_MPRPolygonClicked(object sender, MedicalViewerMPRPolygonClickedEventsArgs e){MedicalViewerMultiCell cell = (MedicalViewerMultiCell)sender;MedicalViewerParaxialCutCell paraxialCell = (MedicalViewerParaxialCutCell)_medicalViewer.Cells[2];// if the user clicks on other polygon lines, the paraxial cut will be assigned to that lineif ((e.Button == MouseButtons.Left) && e.Type == MedicalViewerMPRPolygonHitTest.Body){paraxialCell.PolygonLineIndex = e.Index;}}void cell_PanoramicDataRequested(object sender, MedicalViewerPanoramicDataRequestedEventArgs e){// get the cell that requested the MPR data.MedicalViewerMultiCell cell = (MedicalViewerMultiCell)sender;// instantiate a new raster codecs, which will be used to load the requested image.RasterCodecs _codecs = new RasterCodecs();// the file name of the images loaded in the original cell.String fileName = (string)(_seriesManager.Stacks[0].Items[e.FrameIndex].Data);// load the image and set it to e.Frame.e.Frame = _codecs.Load(fileName, 0, CodecsLoadByteOrder.BgrOrGrayOrRomm, e.FrameIndex + 1, e.FrameIndex + 1);}void MedicalViewerLocalizer_FormClosing(object sender, FormClosingEventArgs e){}void cell_FramesRequested(object sender, MedicalViewerRequestedFramesInformationEventArgs e){MedicalViewerMultiCell cell = (MedicalViewerMultiCell)(sender);RasterCodecs _codecs = new RasterCodecs();int i;RasterImage image;string fileName;if (e.RequestedFramesIndexes.Length > 0){fileName = (string)(_seriesManager.Stacks[0].Items[e.RequestedFramesIndexes[0]].Data);image = _codecs.Load(fileName);}elsereturn;for (i = 1; i < e.RequestedFramesIndexes.Length; i++){fileName = (string)(_seriesManager.Stacks[0].Items[e.RequestedFramesIndexes[i]].Data);image.AddPage(_codecs.Load(fileName));}cell.SetRequestedImage(image, e.RequestedFramesIndexes, MedicalViewerSetImageOptions.Insert);}public MedicalViewer Viewer{get { return _medicalViewer; }}}MedicalViewerMPRPolygonForm GetMedicalViewerMPRPolygonForm(){MedicalViewerSeriesManagerFrom form = new MedicalViewerSeriesManagerFrom();MedicalViewerSeriesManager output = form.LoadJamesHead();return new MedicalViewerMPRPolygonForm(output);}// This example changes the default window level value by decrease the width by 100. Then resets the images based on the new value.public void MedicalViewerMPRPolygonExample(){MedicalViewerMPRPolygonForm myForm = GetMedicalViewerMPRPolygonForm();MedicalViewer medicalViewer = myForm.Viewer;myForm.ShowDialog();}
Imports LeadtoolsImports Leadtools.DicomImports Leadtools.Medical3DImports Leadtools.CodecsImports Leadtools.MedicalViewerImports Leadtools.Annotations.CoreImports Leadtools.Annotations.DesignersImports Leadtools.ImageProcessing.CorePrivate Class MedicalViewerMPRPolygonForm : Inherits FormPrivate _medicalViewer As MedicalViewerPrivate _seriesManager As MedicalViewerSeriesManagerPrivate Sub MedicalViewer_SizeChanged(ByVal sender As Object, ByVal e As EventArgs)_medicalViewer.Size = New Size(Me.ClientRectangle.Right, Me.ClientRectangle.Bottom)End SubPublic Sub New(ByVal output As MedicalViewerSeriesManager)DicomEngine.Startup()Dim _codecs As RasterCodecs = New RasterCodecs()AddHandler SizeChanged, AddressOf MedicalViewer_SizeChanged' Create the medical viewer and adjust the size and the location._medicalViewer = New MedicalViewer(1, 2)_medicalViewer.Location = New Point(0, 0)_medicalViewer.Size = New Size(Me.ClientRectangle.Right, Me.ClientRectangle.Bottom)_seriesManager = outputDim cell As MedicalViewerMultiCell = New MedicalViewerMultiCell(Nothing, True, 1, 1)Dim index As IntegerDim count As Integer = output.Stacks(0).Items.CountDim codecsInformation As CodecsImageInfoDim imageInformation As MedicalViewerImageInformation() = New MedicalViewerImageInformation(count - 1) {}index = 0Do While index < countcodecsInformation = _codecs.GetInformation(CStr(output.Stacks(0).Items(index).Data), True)imageInformation(index) = New MedicalViewerImageInformation()imageInformation(index).ImageHeight = codecsInformation.WidthimageInformation(index).ImageWidth = codecsInformation.WidthimageInformation(index).XResolution = codecsInformation.XResolutionimageInformation(index).YResolution = codecsInformation.YResolutionindex += 1LoopAddHandler cell.FramesRequested, AddressOf cell_FramesRequestedAddHandler FormClosing, AddressOf MedicalViewerLocalizer_FormClosingcell.EnableLowMemoryUsage(2, count, imageInformation)_medicalViewer.Cells.Add(cell)' add some actions that will be used to change the properties of the images inside the control.cell.AddAction(MedicalViewerActionType.WindowLevel)cell.AddAction(MedicalViewerActionType.Alpha)cell.AddAction(MedicalViewerActionType.Offset)' assign the added actions to a mouse button, meaning that when the user clicks and drags the mouse button, the associated action will be activated.cell.SetAction(MedicalViewerActionType.WindowLevel, MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active)cell.SetAction(MedicalViewerActionType.Alpha, MedicalViewerMouseButtons.Middle, MedicalViewerActionFlags.Active)cell.SetAction(MedicalViewerActionType.Offset, MedicalViewerMouseButtons.Right, MedicalViewerActionFlags.Active)cell.ReferenceLine.Enabled = Truecell.ReferenceLine.Color = Color.Yellowcell.ShowCellBoundaries = True' adjust some properties of the cell and add some tags._medicalViewer.Cells(0).SetTag(2, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.UserData, "EX. ID 230-36-5448")_medicalViewer.Cells(0).SetTag(4, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame)_medicalViewer.Cells(0).SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Scale)_medicalViewer.Cells(0).SetTag(2, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.WindowLevelData)_medicalViewer.Cells(0).SetTag(1, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.FieldOfView)cell.PixelSpacing = output.Stacks(0).PixelSpacingindex = 0Do While index < countcell.SetImagePosition(index, output.Stacks(0).Items(index).ImagePosition, (index = count - 1))index += 1Loopcell.ImageOrientation = output.Stacks(0).Items(0).ImageOrientationArraycell.FrameOfReferenceUID = output.Stacks(0).Items(0).FrameOfReferenceUIDDim width As Integer = cell.VirtualImage(cell.ActiveSubCell).Image.WidthDim height As Integer = cell.VirtualImage(cell.ActiveSubCell).Image.HeightControls.Add(_medicalViewer)_medicalViewer.Dock = DockStyle.FillDicomEngine.Shutdown()' create a new polygonDim polygon As MedicalViewerMPRPolygon = New MedicalViewerMPRPolygon()' set some point, here we created a polygon that resembles a rectangle with a missing bottom line.polygon.Points.Add(New PointF(width * 1 \ 4, height * 3 \ 4))polygon.Points.Add(New PointF(width * 1 \ 4, height * 1 \ 4))polygon.Points.Add(New PointF(width * 3 \ 4, height * 1 \ 4))polygon.Points.Add(New PointF(width * 3 \ 4, height * 3 \ 4))' now add this polygon you prepared to the cell.cell.Polygons.Add(polygon)' This event is important, because it's used to request the data that is need to create the internal panoramic data.AddHandler cell.PanoramicDataRequested, AddressOf cell_PanoramicDataRequested' This event communicate with the Medical3D dll which contains all the internal panormaic calculations.AddHandler cell.Data3DRequested, AddressOf cell_Data3DRequested' Dispose the internal data automatically if the use decided to delete the polygon.cell.AutoDisposeInternalData = True' register the polygon clickAddHandler cell.MPRPolygonClicked, AddressOf cell_MPRPolygonClickedCreatePanoramicCell(cell, polygon)polygon.Recalculate()End SubPrivate Sub cell_Data3DRequested(ByVal sender As Object, ByVal e As MedicalViewerData3DRequestedEventArgs)e.Succeed = Medical3DEngine.Provide3DInformation(e)End SubPrivate Sub CreatePanoramicCell(ByVal cellSource As MedicalViewerMultiCell, ByVal polygon As MedicalViewerMPRPolygon)' create a new panoramic cell assigned to the polygon you created.Dim cell As MedicalViewerPanoramicCell = New MedicalViewerPanoramicCell(polygon)' add some action, not necessary though.cell.AddAction(MedicalViewerActionType.WindowLevel)cell.AddAction(MedicalViewerActionType.Scale)cell.AddAction(MedicalViewerActionType.Offset)cell.AddAction(MedicalViewerActionType.Stack)cell.SetAction(MedicalViewerActionType.Offset, MedicalViewerMouseButtons.Right, MedicalViewerActionFlags.AllCells Or MedicalViewerActionFlags.RealTime)cell.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active)cell.SetAction(MedicalViewerActionType.Scale, MedicalViewerMouseButtons.Middle, MedicalViewerActionFlags.Active)' Add the panoramic cell the viewer._medicalViewer.Cells.Add(cell)' Create a paraxial cell, and assign it to the polygon you just created.Dim paraxialCell As MedicalViewerParaxialCutCell = New MedicalViewerParaxialCutCell(polygon, 0)' set the distance and the length of the paraxial cuts.paraxialCell.ParaxialDistance = 20paraxialCell.ParaxialLength = 200' Add the paraxial cuts to the viewer._medicalViewer.Cells.Add(paraxialCell)End SubPrivate Sub cell_MPRPolygonClicked(ByVal sender As Object, ByVal e As MedicalViewerMPRPolygonClickedEventsArgs)Dim cell As MedicalViewerMultiCell = CType(sender, MedicalViewerMultiCell)Dim paraxialCell As MedicalViewerParaxialCutCell = CType(_medicalViewer.Cells(2), MedicalViewerParaxialCutCell)' if the user clicks on other polygon lines, the paraxial cut will be assigned to that lineIf (e.Button = MouseButtons.Left) AndAlso e.Type = MedicalViewerMPRPolygonHitTest.Body ThenparaxialCell.PolygonLineIndex = e.IndexEnd IfEnd SubPrivate Sub cell_PanoramicDataRequested(ByVal sender As Object, ByVal e As MedicalViewerPanoramicDataRequestedEventArgs)' get the cell that requested the MPR data.Dim cell As MedicalViewerMultiCell = CType(sender, MedicalViewerMultiCell)' instantiate a new raster codecs, which will be used to load the requested image.Dim _codecs As RasterCodecs = New RasterCodecs()' the file name of the images loaded in the original cell.Dim fileName As String = CStr(_seriesManager.Stacks(0).Items(e.FrameIndex).Data)' load the image and set it to e.Frame.e.Frame = _codecs.Load(fileName, 0, CodecsLoadByteOrder.BgrOrGrayOrRomm, e.FrameIndex + 1, e.FrameIndex + 1)End SubPrivate Sub MedicalViewerLocalizer_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs)End SubPrivate Sub cell_FramesRequested(ByVal sender As Object, ByVal e As MedicalViewerRequestedFramesInformationEventArgs)Dim cell As MedicalViewerMultiCell = CType(sender, MedicalViewerMultiCell)Dim _codecs As RasterCodecs = New RasterCodecs()Dim i As IntegerDim image As RasterImageDim fileName As StringIf e.RequestedFramesIndexes.Length > 0 ThenfileName = CStr(_seriesManager.Stacks(0).Items(e.RequestedFramesIndexes(0)).Data)image = _codecs.Load(fileName)ElseReturnEnd Ifi = 1Do While i < e.RequestedFramesIndexes.LengthfileName = CStr(_seriesManager.Stacks(0).Items(e.RequestedFramesIndexes(i)).Data)image.AddPage(_codecs.Load(fileName))i += 1Loopcell.SetRequestedImage(image, e.RequestedFramesIndexes, MedicalViewerSetImageOptions.Insert)End SubPublic ReadOnly Property Viewer() As MedicalViewerGetReturn _medicalViewerEnd GetEnd PropertyEnd ClassPrivate Function GetMedicalViewerMPRPolygonForm() As MedicalViewerMPRPolygonFormDim form As MedicalViewerSeriesManagerFrom = New MedicalViewerSeriesManagerFrom()Dim output As MedicalViewerSeriesManager = form.LoadJamesHead()Return New MedicalViewerMPRPolygonForm(output)End Function' This example changes the default window level value by decrease the width by 100. Then resets the images based on the new value.<TestMethod()> _Public Sub MedicalViewerMPRPolygonExample()Dim myForm As MedicalViewerMPRPolygonForm = GetMedicalViewerMPRPolygonForm()Dim medicalViewer As MedicalViewer = myForm.ViewermyForm.ShowDialog()End Sub
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
