LEADTOOLS Medical (Leadtools.MedicalViewer assembly)

MedicalViewerMPRCell Class

Show in webframe





Members 
Represents the class that is used to create an MPR cell.
Object Model
Syntax
Remarks

For more information, refer to Image Viewer Cells.

Example
        Imports Leadtools
        Imports Leadtools.Dicom
        Imports Leadtools.Medical3D
        Imports Leadtools.Codecs
        Imports Leadtools.MedicalViewer
        Imports Leadtools.Annotations
        Imports Leadtools.ImageProcessing.Core

        Private Class MedicalViewerMPRForm : Inherits Form
            Private _medicalViewer As MedicalViewer
            Private _seriesManager As MedicalViewerSeriesManager
            Private Sub MedicalViewerMPRForm_SizeChanged(ByVal sender As Object, ByVal e As EventArgs)
                _medicalViewer.Size = New Size(Me.ClientRectangle.Right, Me.ClientRectangle.Bottom)
            End Sub

            Public Sub New(ByVal output As MedicalViewerSeriesManager)
                Dim _codecs As RasterCodecs = New RasterCodecs()

                AddHandler SizeChanged, AddressOf MedicalViewerMPRForm_SizeChanged

                ' Create the medical viewer and adjust the size and the location.
                _medicalViewer = New MedicalViewer(2, 2)
                _medicalViewer.Location = New Point(0, 0)
                _medicalViewer.Size = New Size(Me.ClientRectangle.Right, Me.ClientRectangle.Bottom)

                _seriesManager = output

                Dim index As Integer
                Dim image As RasterImage
                Dim count As Integer = output.Stacks(0).Items.Count
                Dim codecsInformation As CodecsImageInfo

                Dim AxialFrame As MedicalViewerMPRCell = New MedicalViewerMPRCell()
                Dim SagittalFrame As MedicalViewerMPRCell = New MedicalViewerMPRCell()
                Dim CoronalFrame As MedicalViewerMPRCell = New MedicalViewerMPRCell()

                codecsInformation = _codecs.GetInformation(CStr(output.Stacks(0).Items(0).Data), True)

                Dim width As Integer = codecsInformation.Width
                Dim height As Integer = codecsInformation.Height
                Dim depth As Integer = 256

                ' Create a 3D control.
                Dim _medical3DControl As Medical3DControl = New Medical3DControl()

                _medical3DControl.ObjectsContainer.VolumeType = Medical3DVolumeType.MPR
                _medical3DControl.ObjectsContainer.Objects.Add(New Medical3DObject())

                ' Create a 3D object.

                _medical3DControl.ObjectsContainer.Objects(0).MemoryEfficientInit(depth)

                index = 0
                Do While index < depth
                    image = _codecs.Load(CStr(output.Stacks(0).Items(index).Data), 0, CodecsLoadByteOrder.BgrOrGrayOrRomm, 1, 1)
                    _medical3DControl.ObjectsContainer.Objects(0).MemoryEfficientSetFrame(image, index, True)
                    index += 1
                Loop

                Dim spearator As String = ("\")
                Dim test As String() = output.Stacks(0).Items(0).ImageOrientation.Split(spearator.ToCharArray())
                Dim orientation As Single() = New Single(5) {}
                Dim i As Integer
                For i = 0 To 5
                    orientation(i) = CSng(Convert.ToDouble(test(i)))
                Next i

                _medical3DControl.ObjectsContainer.Objects(0).MemoryEfficientEnd(orientation, output.Stacks(0).PixelSpacing)

                ' Create axial frame
                AxialFrame.ShowMPRCrossHair = True
                AxialFrame.DistinguishMPRByColor = True
                AxialFrame.SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame)
                AxialFrame.AddAction(MedicalViewerActionType.Stack)
                AxialFrame.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active)


                ' Create Sagittal frame
                SagittalFrame.ShowMPRCrossHair = True
                SagittalFrame.DistinguishMPRByColor = True
                SagittalFrame.SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame)
                SagittalFrame.AddAction(MedicalViewerActionType.Stack)
                SagittalFrame.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active)

                ' Create coronal frame
                CoronalFrame.ShowMPRCrossHair = True
                CoronalFrame.DistinguishMPRByColor = True
                CoronalFrame.SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame)
                CoronalFrame.AddAction(MedicalViewerActionType.Stack)
                CoronalFrame.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active)

                ' attach the MPR cells to the 3D control
                _medical3DControl.AxialFrame = AxialFrame
                _medical3DControl.SagittalFrame = SagittalFrame
                _medical3DControl.CoronalFrame = CoronalFrame


                AxialFrame.AxialName = "Axial Cell"
                SagittalFrame.SagittalName = "Sagittal Cell"
                CoronalFrame.CoronalName = "Coronal Cell"

                AxialFrame.SetTag(1, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.MPRType)
                SagittalFrame.SetTag(1, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.MPRType)
                CoronalFrame.SetTag(1, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.MPRType)

                ' with this option, you will not be able to select more than one cell at the same time. (selecting multiple cells are done with the pressing and holding the Ctrl and clicking on cell)
                _medicalViewer.AllowMultipleSelection = False

                _medicalViewer.Cells.Add(_medical3DControl)
                _medicalViewer.Cells.Add(AxialFrame)
                _medicalViewer.Cells.Add(SagittalFrame)
                _medicalViewer.Cells.Add(CoronalFrame)

                Controls.Add(_medicalViewer)
                _medicalViewer.Dock = DockStyle.Fill
            End Sub

            ' This event handles communication between the the 3D and the MedicalViewer.
            Private Sub cell_Data3DRequested(ByVal sender As Object, ByVal e As MedicalViewerData3DRequestedEventArgs)
                e.Succeed = Medical3DEngine.Provide3DInformation(e)
            End Sub

            Private 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 Integer
                Dim image As RasterImage
                Dim fileName As String

                If e.RequestedFramesIndexes.Length > 0 Then
                    fileName = CStr(_seriesManager.Stacks(0).Items(e.RequestedFramesIndexes(0)).Data)
                    image = _codecs.Load(fileName)
                Else
                    Return
                End If

                i = 1
                Do While i < e.RequestedFramesIndexes.Length
                    fileName = CStr(_seriesManager.Stacks(0).Items(e.RequestedFramesIndexes(i)).Data)
                    image.AddPage(_codecs.Load(fileName))
                    i += 1
                Loop

                cell.SetRequestedImage(image, e.RequestedFramesIndexes, MedicalViewerSetImageOptions.Insert)
            End Sub

            Public ReadOnly Property Viewer() As MedicalViewer
                Get
                    Return _medicalViewer
                End Get
            End Property
        End Class

        Private Function GetMedicalViewerMPRForm() As MedicalViewerMPRForm
            Dim form As MedicalViewerSeriesManagerFrom = New MedicalViewerSeriesManagerFrom()
            Dim output As MedicalViewerSeriesManager = form.LoadJamesHead()

            Return New MedicalViewerMPRForm(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.

        Public Sub MedicalViewerMPRExample()
            Dim myForm As MedicalViewerMPRForm = GetMedicalViewerMPRForm()
            Dim medicalViewer As MedicalViewer = myForm.Viewer

            myForm.ShowDialog()
        End Sub      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;

      class MedicalViewerMPRForm : Form
      {
         private MedicalViewer _medicalViewer;
         private MedicalViewerSeriesManager _seriesManager;
         void MedicalViewerMPRForm_SizeChanged(object sender, EventArgs e)
         {
            _medicalViewer.Size = new Size(this.ClientRectangle.Right, this.ClientRectangle.Bottom);
         }

         public MedicalViewerMPRForm(MedicalViewerSeriesManager output)
         {
            RasterCodecs _codecs = new RasterCodecs();

            this.SizeChanged += new EventHandler(MedicalViewerMPRForm_SizeChanged);

            // Create the medical viewer and adjust the size and the location.
            _medicalViewer = new MedicalViewer(2, 2);
            _medicalViewer.Location = new Point(0, 0);
            _medicalViewer.Size = new Size(this.ClientRectangle.Right, this.ClientRectangle.Bottom);

            _seriesManager = output;

            int index;
            RasterImage image;
            int count = output.Stacks[0].Items.Count;
            CodecsImageInfo codecsInformation;

            MedicalViewerMPRCell AxialFrame = new MedicalViewerMPRCell();
            MedicalViewerMPRCell SagittalFrame = new MedicalViewerMPRCell();
            MedicalViewerMPRCell CoronalFrame = new MedicalViewerMPRCell();

            codecsInformation = _codecs.GetInformation((string)output.Stacks[0].Items[0].Data, true);

            int width = codecsInformation.Width;
            int height = codecsInformation.Height;
            int depth = 256;

            // Create a 3D control.
            Medical3DControl _medical3DControl = new Medical3DControl();

            _medical3DControl.ObjectsContainer.VolumeType = Medical3DVolumeType.MPR;
            _medical3DControl.ObjectsContainer.Objects.Add(new Medical3DObject());

            // Create a 3D object.

            _medical3DControl.ObjectsContainer.Objects[0].MemoryEfficientInit(depth);

            for (index = 0; index < depth; index++)
            {
               image = _codecs.Load((string)output.Stacks[0].Items[index].Data, 0, CodecsLoadByteOrder.BgrOrGrayOrRomm, 1, 1);
               _medical3DControl.ObjectsContainer.Objects[0].MemoryEfficientSetFrame(image, index, true);
            }

            string spearator = ("\\");
            string[] test = output.Stacks[0].Items[0].ImageOrientation.Split(spearator.ToCharArray());
            float[] orientation = new float[6];
            int i;
            for (i = 0; i < 6; i++)
            {
               orientation[i] = (float)Convert.ToDouble(test[i]);
            }

            _medical3DControl.ObjectsContainer.Objects[0].MemoryEfficientEnd(orientation,
                                                                             output.Stacks[0].PixelSpacing);

            // Create axial frame
            AxialFrame.ShowMPRCrossHair = true;
            AxialFrame.DistinguishMPRByColor = true;
            AxialFrame.SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame);
            AxialFrame.AddAction(MedicalViewerActionType.Stack);
            AxialFrame.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active);


            // Create Sagittal frame
            SagittalFrame.ShowMPRCrossHair = true;
            SagittalFrame.DistinguishMPRByColor = true;
            SagittalFrame.SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame);
            SagittalFrame.AddAction(MedicalViewerActionType.Stack);
            SagittalFrame.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active);

            // Create coronal frame
            CoronalFrame.ShowMPRCrossHair = true;
            CoronalFrame.DistinguishMPRByColor = true;
            CoronalFrame.SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame);
            CoronalFrame.AddAction(MedicalViewerActionType.Stack);
            CoronalFrame.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active);

            // attach the MPR cells to the 3D control
            _medical3DControl.AxialFrame    = AxialFrame;
            _medical3DControl.SagittalFrame = SagittalFrame;
            _medical3DControl.CoronalFrame  = CoronalFrame;

            AxialFrame.AxialName = "Axial Cell";
            SagittalFrame.SagittalName = "Sagittal Cell";
            CoronalFrame.CoronalName = "Coronal Cell";

            AxialFrame.SetTag(1, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.MPRType);
            SagittalFrame.SetTag(1, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.MPRType);
            CoronalFrame.SetTag(1, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.MPRType);

            // with this option, you will not be able to select more than one cell at the same time. (selecting multiple cells are done with the pressing and holding the Ctrl and clicking on cell)
            _medicalViewer.AllowMultipleSelection = false;

            _medicalViewer.Cells.Add(_medical3DControl);
            _medicalViewer.Cells.Add(AxialFrame);
            _medicalViewer.Cells.Add(SagittalFrame);
            _medicalViewer.Cells.Add(CoronalFrame);

            Controls.Add(_medicalViewer);
            _medicalViewer.Dock = DockStyle.Fill;
         }

         // This event handles communication between the the 3D and the MedicalViewer.
         void cell_Data3DRequested(object sender, MedicalViewerData3DRequestedEventArgs e)
         {
            e.Succeed = Medical3DEngine.Provide3DInformation(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);
            }
            else
               return;

            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; }
         }
      }

      MedicalViewerMPRForm GetMedicalViewerMPRForm()
      {
         MedicalViewerSeriesManagerFrom form = new MedicalViewerSeriesManagerFrom();
         MedicalViewerSeriesManager output = form.LoadJamesHead();

         return new MedicalViewerMPRForm(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 MedicalViewerMPRExample()
      {
         MedicalViewerMPRForm myForm = GetMedicalViewerMPRForm();
         MedicalViewer medicalViewer = myForm.Viewer;

         myForm.ShowDialog();
      }
        Imports Leadtools
        Imports Leadtools.Dicom
        Imports Leadtools.Medical3D
        Imports Leadtools.Codecs
        Imports Leadtools.MedicalViewer
        Imports Leadtools.Annotations
        Imports Leadtools.ImageProcessing.Core

        Private Class MedicalViewerMPRForm : Inherits Form
            Private _medicalViewer As MedicalViewer
            Private _seriesManager As MedicalViewerSeriesManager
            Private Sub MedicalViewerMPRForm_SizeChanged(ByVal sender As Object, ByVal e As EventArgs)
                _medicalViewer.Size = New Size(Me.ClientRectangle.Right, Me.ClientRectangle.Bottom)
            End Sub

            Public Sub New(ByVal output As MedicalViewerSeriesManager)
                Dim _codecs As RasterCodecs = New RasterCodecs()

                AddHandler SizeChanged, AddressOf MedicalViewerMPRForm_SizeChanged

                ' Create the medical viewer and adjust the size and the location.
                _medicalViewer = New MedicalViewer(2, 2)
                _medicalViewer.Location = New Point(0, 0)
                _medicalViewer.Size = New Size(Me.ClientRectangle.Right, Me.ClientRectangle.Bottom)

                _seriesManager = output

                Dim index As Integer
                Dim image As RasterImage
                Dim count As Integer = output.Stacks(0).Items.Count
                Dim codecsInformation As CodecsImageInfo

                Dim AxialFrame As MedicalViewerMPRCell = New MedicalViewerMPRCell()
                Dim SagittalFrame As MedicalViewerMPRCell = New MedicalViewerMPRCell()
                Dim CoronalFrame As MedicalViewerMPRCell = New MedicalViewerMPRCell()

                codecsInformation = _codecs.GetInformation(CStr(output.Stacks(0).Items(0).Data), True)

                Dim width As Integer = codecsInformation.Width
                Dim height As Integer = codecsInformation.Height
                Dim depth As Integer = 256

                ' Create a 3D control.
                Dim _medical3DControl As Medical3DControl = New Medical3DControl()

                _medical3DControl.ObjectsContainer.VolumeType = Medical3DVolumeType.MPR
                _medical3DControl.ObjectsContainer.Objects.Add(New Medical3DObject())

                ' Create a 3D object.

                _medical3DControl.ObjectsContainer.Objects(0).MemoryEfficientInit(depth)

                index = 0
                Do While index < depth
                    image = _codecs.Load(CStr(output.Stacks(0).Items(index).Data), 0, CodecsLoadByteOrder.BgrOrGrayOrRomm, 1, 1)
                    _medical3DControl.ObjectsContainer.Objects(0).MemoryEfficientSetFrame(image, index, True)
                    index += 1
                Loop

                Dim spearator As String = ("\")
                Dim test As String() = output.Stacks(0).Items(0).ImageOrientation.Split(spearator.ToCharArray())
                Dim orientation As Single() = New Single(5) {}
                Dim i As Integer
                For i = 0 To 5
                    orientation(i) = CSng(Convert.ToDouble(test(i)))
                Next i

                _medical3DControl.ObjectsContainer.Objects(0).MemoryEfficientEnd(orientation, output.Stacks(0).PixelSpacing)

                ' Create axial frame
                AxialFrame.ShowMPRCrossHair = True
                AxialFrame.DistinguishMPRByColor = True
                AxialFrame.SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame)
                AxialFrame.AddAction(MedicalViewerActionType.Stack)
                AxialFrame.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active)


                ' Create Sagittal frame
                SagittalFrame.ShowMPRCrossHair = True
                SagittalFrame.DistinguishMPRByColor = True
                SagittalFrame.SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame)
                SagittalFrame.AddAction(MedicalViewerActionType.Stack)
                SagittalFrame.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active)

                ' Create coronal frame
                CoronalFrame.ShowMPRCrossHair = True
                CoronalFrame.DistinguishMPRByColor = True
                CoronalFrame.SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame)
                CoronalFrame.AddAction(MedicalViewerActionType.Stack)
                CoronalFrame.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active)

                ' attach the MPR cells to the 3D control
                _medical3DControl.AxialFrame = AxialFrame
                _medical3DControl.SagittalFrame = SagittalFrame
                _medical3DControl.CoronalFrame = CoronalFrame


                AxialFrame.AxialName = "Axial Cell"
                SagittalFrame.SagittalName = "Sagittal Cell"
                CoronalFrame.CoronalName = "Coronal Cell"

                AxialFrame.SetTag(1, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.MPRType)
                SagittalFrame.SetTag(1, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.MPRType)
                CoronalFrame.SetTag(1, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.MPRType)

                ' with this option, you will not be able to select more than one cell at the same time. (selecting multiple cells are done with the pressing and holding the Ctrl and clicking on cell)
                _medicalViewer.AllowMultipleSelection = False

                _medicalViewer.Cells.Add(_medical3DControl)
                _medicalViewer.Cells.Add(AxialFrame)
                _medicalViewer.Cells.Add(SagittalFrame)
                _medicalViewer.Cells.Add(CoronalFrame)

                Controls.Add(_medicalViewer)
                _medicalViewer.Dock = DockStyle.Fill
            End Sub

            ' This event handles communication between the the 3D and the MedicalViewer.
            Private Sub cell_Data3DRequested(ByVal sender As Object, ByVal e As MedicalViewerData3DRequestedEventArgs)
                e.Succeed = Medical3DEngine.Provide3DInformation(e)
            End Sub

            Private 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 Integer
                Dim image As RasterImage
                Dim fileName As String

                If e.RequestedFramesIndexes.Length > 0 Then
                    fileName = CStr(_seriesManager.Stacks(0).Items(e.RequestedFramesIndexes(0)).Data)
                    image = _codecs.Load(fileName)
                Else
                    Return
                End If

                i = 1
                Do While i < e.RequestedFramesIndexes.Length
                    fileName = CStr(_seriesManager.Stacks(0).Items(e.RequestedFramesIndexes(i)).Data)
                    image.AddPage(_codecs.Load(fileName))
                    i += 1
                Loop

                cell.SetRequestedImage(image, e.RequestedFramesIndexes, MedicalViewerSetImageOptions.Insert)
            End Sub

            Public ReadOnly Property Viewer() As MedicalViewer
                Get
                    Return _medicalViewer
                End Get
            End Property
        End Class

        Private Function GetMedicalViewerMPRForm() As MedicalViewerMPRForm
            Dim form As MedicalViewerSeriesManagerFrom = New MedicalViewerSeriesManagerFrom()
            Dim output As MedicalViewerSeriesManager = form.LoadJamesHead()

            Return New MedicalViewerMPRForm(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.

        Public Sub MedicalViewerMPRExample()
            Dim myForm As MedicalViewerMPRForm = GetMedicalViewerMPRForm()
            Dim medicalViewer As MedicalViewer = myForm.Viewer

            myForm.ShowDialog()
        End Sub      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;

      class MedicalViewerMPRForm : Form
      {
         private MedicalViewer _medicalViewer;
         private MedicalViewerSeriesManager _seriesManager;
         void MedicalViewerMPRForm_SizeChanged(object sender, EventArgs e)
         {
            _medicalViewer.Size = new Size(this.ClientRectangle.Right, this.ClientRectangle.Bottom);
         }

         public MedicalViewerMPRForm(MedicalViewerSeriesManager output)
         {
            RasterCodecs _codecs = new RasterCodecs();

            this.SizeChanged += new EventHandler(MedicalViewerMPRForm_SizeChanged);

            // Create the medical viewer and adjust the size and the location.
            _medicalViewer = new MedicalViewer(2, 2);
            _medicalViewer.Location = new Point(0, 0);
            _medicalViewer.Size = new Size(this.ClientRectangle.Right, this.ClientRectangle.Bottom);

            _seriesManager = output;

            int index;
            RasterImage image;
            int count = output.Stacks[0].Items.Count;
            CodecsImageInfo codecsInformation;

            MedicalViewerMPRCell AxialFrame = new MedicalViewerMPRCell();
            MedicalViewerMPRCell SagittalFrame = new MedicalViewerMPRCell();
            MedicalViewerMPRCell CoronalFrame = new MedicalViewerMPRCell();

            codecsInformation = _codecs.GetInformation((string)output.Stacks[0].Items[0].Data, true);

            int width = codecsInformation.Width;
            int height = codecsInformation.Height;
            int depth = 256;

            // Create a 3D control.
            Medical3DControl _medical3DControl = new Medical3DControl();

            _medical3DControl.ObjectsContainer.VolumeType = Medical3DVolumeType.MPR;
            _medical3DControl.ObjectsContainer.Objects.Add(new Medical3DObject());

            // Create a 3D object.

            _medical3DControl.ObjectsContainer.Objects[0].MemoryEfficientInit(depth);

            for (index = 0; index < depth; index++)
            {
               image = _codecs.Load((string)output.Stacks[0].Items[index].Data, 0, CodecsLoadByteOrder.BgrOrGrayOrRomm, 1, 1);
               _medical3DControl.ObjectsContainer.Objects[0].MemoryEfficientSetFrame(image, index, true);
            }

            string spearator = ("\\");
            string[] test = output.Stacks[0].Items[0].ImageOrientation.Split(spearator.ToCharArray());
            float[] orientation = new float[6];
            int i;
            for (i = 0; i < 6; i++)
            {
               orientation[i] = (float)Convert.ToDouble(test[i]);
            }

            _medical3DControl.ObjectsContainer.Objects[0].MemoryEfficientEnd(orientation,
                                                                             output.Stacks[0].PixelSpacing);

            // Create axial frame
            AxialFrame.ShowMPRCrossHair = true;
            AxialFrame.DistinguishMPRByColor = true;
            AxialFrame.SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame);
            AxialFrame.AddAction(MedicalViewerActionType.Stack);
            AxialFrame.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active);


            // Create Sagittal frame
            SagittalFrame.ShowMPRCrossHair = true;
            SagittalFrame.DistinguishMPRByColor = true;
            SagittalFrame.SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame);
            SagittalFrame.AddAction(MedicalViewerActionType.Stack);
            SagittalFrame.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active);

            // Create coronal frame
            CoronalFrame.ShowMPRCrossHair = true;
            CoronalFrame.DistinguishMPRByColor = true;
            CoronalFrame.SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame);
            CoronalFrame.AddAction(MedicalViewerActionType.Stack);
            CoronalFrame.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active);

            // attach the MPR cells to the 3D control
            _medical3DControl.AxialFrame    = AxialFrame;
            _medical3DControl.SagittalFrame = SagittalFrame;
            _medical3DControl.CoronalFrame  = CoronalFrame;

            AxialFrame.AxialName = "Axial Cell";
            SagittalFrame.SagittalName = "Sagittal Cell";
            CoronalFrame.CoronalName = "Coronal Cell";

            AxialFrame.SetTag(1, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.MPRType);
            SagittalFrame.SetTag(1, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.MPRType);
            CoronalFrame.SetTag(1, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.MPRType);

            // with this option, you will not be able to select more than one cell at the same time. (selecting multiple cells are done with the pressing and holding the Ctrl and clicking on cell)
            _medicalViewer.AllowMultipleSelection = false;

            _medicalViewer.Cells.Add(_medical3DControl);
            _medicalViewer.Cells.Add(AxialFrame);
            _medicalViewer.Cells.Add(SagittalFrame);
            _medicalViewer.Cells.Add(CoronalFrame);

            Controls.Add(_medicalViewer);
            _medicalViewer.Dock = DockStyle.Fill;
         }

         // This event handles communication between the the 3D and the MedicalViewer.
         void cell_Data3DRequested(object sender, MedicalViewerData3DRequestedEventArgs e)
         {
            e.Succeed = Medical3DEngine.Provide3DInformation(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);
            }
            else
               return;

            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; }
         }
      }

      MedicalViewerMPRForm GetMedicalViewerMPRForm()
      {
         MedicalViewerSeriesManagerFrom form = new MedicalViewerSeriesManagerFrom();
         MedicalViewerSeriesManager output = form.LoadJamesHead();

         return new MedicalViewerMPRForm(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 MedicalViewerMPRExample()
      {
         MedicalViewerMPRForm myForm = GetMedicalViewerMPRForm();
         MedicalViewer medicalViewer = myForm.Viewer;

         myForm.ShowDialog();
      }
      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;

      class MedicalViewerMPRForm : Form
      {
         private MedicalViewer _medicalViewer;
         private MedicalViewerSeriesManager _seriesManager;
         void MedicalViewerMPRForm_SizeChanged(object sender, EventArgs e)
         {
            _medicalViewer.Size = new Size(this.ClientRectangle.Right, this.ClientRectangle.Bottom);
         }

         public MedicalViewerMPRForm(MedicalViewerSeriesManager output)
         {
            RasterCodecs _codecs = new RasterCodecs();

            this.SizeChanged += new EventHandler(MedicalViewerMPRForm_SizeChanged);

            // Create the medical viewer and adjust the size and the location.
            _medicalViewer = new MedicalViewer(2, 2);
            _medicalViewer.Location = new Point(0, 0);
            _medicalViewer.Size = new Size(this.ClientRectangle.Right, this.ClientRectangle.Bottom);

            _seriesManager = output;

            int index;
            RasterImage image;
            int count = output.Stacks[0].Items.Count;
            CodecsImageInfo codecsInformation;

            MedicalViewerMPRCell AxialFrame = new MedicalViewerMPRCell();
            MedicalViewerMPRCell SagittalFrame = new MedicalViewerMPRCell();
            MedicalViewerMPRCell CoronalFrame = new MedicalViewerMPRCell();

            codecsInformation = _codecs.GetInformation((string)output.Stacks[0].Items[0].Data, true);

            int width = codecsInformation.Width;
            int height = codecsInformation.Height;
            int depth = 256;

            // Create a 3D control.
            Medical3DControl _medical3DControl = new Medical3DControl();

            _medical3DControl.ObjectsContainer.VolumeType = Medical3DVolumeType.MPR;
            _medical3DControl.ObjectsContainer.Objects.Add(new Medical3DObject());

            // Create a 3D object.

            _medical3DControl.ObjectsContainer.Objects[0].MemoryEfficientInit(depth);

            for (index = 0; index < depth; index++)
            {
               image = _codecs.Load((string)output.Stacks[0].Items[index].Data, 0, CodecsLoadByteOrder.BgrOrGrayOrRomm, 1, 1);
               _medical3DControl.ObjectsContainer.Objects[0].MemoryEfficientSetFrame(image, index, true);
            }

            string spearator = ("\\");
            string[] test = output.Stacks[0].Items[0].ImageOrientation.Split(spearator.ToCharArray());
            float[] orientation = new float[6];
            int i;
            for (i = 0; i < 6; i++)
            {
               orientation[i] = (float)Convert.ToDouble(test[i]);
            }

            _medical3DControl.ObjectsContainer.Objects[0].MemoryEfficientEnd(orientation,
                                                                             output.Stacks[0].PixelSpacing);

            // Create axial frame
            AxialFrame.ShowMPRCrossHair = true;
            AxialFrame.DistinguishMPRByColor = true;
            AxialFrame.SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame);
            AxialFrame.AddAction(MedicalViewerActionType.Stack);
            AxialFrame.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active);


            // Create Sagittal frame
            SagittalFrame.ShowMPRCrossHair = true;
            SagittalFrame.DistinguishMPRByColor = true;
            SagittalFrame.SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame);
            SagittalFrame.AddAction(MedicalViewerActionType.Stack);
            SagittalFrame.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active);

            // Create coronal frame
            CoronalFrame.ShowMPRCrossHair = true;
            CoronalFrame.DistinguishMPRByColor = true;
            CoronalFrame.SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame);
            CoronalFrame.AddAction(MedicalViewerActionType.Stack);
            CoronalFrame.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active);

            // attach the MPR cells to the 3D control
            _medical3DControl.AxialFrame    = AxialFrame;
            _medical3DControl.SagittalFrame = SagittalFrame;
            _medical3DControl.CoronalFrame  = CoronalFrame;

            AxialFrame.AxialName = "Axial Cell";
            SagittalFrame.SagittalName = "Sagittal Cell";
            CoronalFrame.CoronalName = "Coronal Cell";

            AxialFrame.SetTag(1, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.MPRType);
            SagittalFrame.SetTag(1, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.MPRType);
            CoronalFrame.SetTag(1, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.MPRType);

            // with this option, you will not be able to select more than one cell at the same time. (selecting multiple cells are done with the pressing and holding the Ctrl and clicking on cell)
            _medicalViewer.AllowMultipleSelection = false;

            _medicalViewer.Cells.Add(_medical3DControl);
            _medicalViewer.Cells.Add(AxialFrame);
            _medicalViewer.Cells.Add(SagittalFrame);
            _medicalViewer.Cells.Add(CoronalFrame);

            Controls.Add(_medicalViewer);
            _medicalViewer.Dock = DockStyle.Fill;
         }

         // This event handles communication between the the 3D and the MedicalViewer.
         void cell_Data3DRequested(object sender, MedicalViewerData3DRequestedEventArgs e)
         {
            e.Succeed = Medical3DEngine.Provide3DInformation(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);
            }
            else
               return;

            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; }
         }
      }

      MedicalViewerMPRForm GetMedicalViewerMPRForm()
      {
         MedicalViewerSeriesManagerFrom form = new MedicalViewerSeriesManagerFrom();
         MedicalViewerSeriesManager output = form.LoadJamesHead();

         return new MedicalViewerMPRForm(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 MedicalViewerMPRExample()
      {
         MedicalViewerMPRForm myForm = GetMedicalViewerMPRForm();
         MedicalViewer medicalViewer = myForm.Viewer;

         myForm.ShowDialog();
      }
Requirements

Target Platforms

See Also

Reference

MedicalViewerMPRCell Members
Leadtools.MedicalViewer Namespace

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.

Leadtools.MedicalViewer requires a Medical Imaging license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features