轉(zhuǎn)帖|使用教程|編輯:龔雪|2015-11-19 13:31:26.000|閱讀 645 次
概述:本教程是關(guān)于位圖圖像處理控件LEADTOOLS使用教程:MPR視圖創(chuàng)建3D對(duì)象。其中附有VB和C#代碼,可供參考。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷(xiāo)售中 >>
相關(guān)鏈接:
本教程可以教您如何創(chuàng)建一個(gè)3D對(duì)象,和如何將三個(gè)MPR正交切片(軸向,矢狀和冠狀)呈現(xiàn)在一個(gè)單元格窗體上。
1.首先,請(qǐng)您啟動(dòng)在創(chuàng)建一個(gè)3D對(duì)象時(shí)所創(chuàng)建的那個(gè)項(xiàng)目。
2.現(xiàn)在,請(qǐng)運(yùn)行程序,您將看到一個(gè)2x2的布局,其中的每一個(gè)間隔都是以3D對(duì)象為填充的。
3.現(xiàn)在,請(qǐng)您添加三個(gè)MPR單元格:
創(chuàng)建一個(gè)MedicalViewerMPRCell的新實(shí)例,并改變它的屬性,以滿(mǎn)足您的需求。在本演示程序中,我們將創(chuàng)建一個(gè)軸向單元格。為了做到這一點(diǎn),請(qǐng)將以下幾行代碼添加到InitClass方法的底部:
[Visual Basic]
 ' 創(chuàng)建一個(gè)包含軸向框架的新單元格。
            Dim axialCell As MedicalViewerMPRCell = New MedicalViewerMPRCell()
            ' 調(diào)整其部分屬性以查看十字線。
            axialCell.ShowMPRCrossHair = True
            axialCell.DistinguishMPRByColor = True
C#
 // 創(chuàng)建一個(gè)包含軸向框架的新單元格。
            MedicalViewerMPRCell axialCell = new MedicalViewerMPRCell();
            // 調(diào)整其部分屬性以查看十字線。
            axialCell.ShowMPRCrossHair = true;
            axialCell.DistinguishMPRByColor = true;
4.通過(guò)AxialFrame屬性將軸向單元格分配給Medical3DControl。為了做到這一點(diǎn),請(qǐng)將以下一行代碼添加到InitClass方法的底部:
[Visual Basic]
' 將該單元格 (axialCell) 分配到Medical3DControl的AxialFrame 屬性。
            control3D.AxialFrame = axialCell
C#
 // 將該單元格 (axialCell) 分配到Medical3DControl的AxialFrame 屬性。
            control3D.AxialFrame = axialCell;
5.最后,將所創(chuàng)建的實(shí)例添加到查看器。為了做到這一點(diǎn),請(qǐng)將以下一行代碼添加到InitClass方法的底部:
[Visual Base]
  ' 將該軸向單元格添加到查看器
            viewer.Cells.Add(axialCell)
C#
 // 將該軸向單元格添加到查看器
            viewer.Cells.Add(axialCell);
6.重復(fù)以上的3,4和5這幾個(gè)步驟,以創(chuàng)建矢狀和冠狀單元格。但是,請(qǐng)注意這一點(diǎn),在步驟4.中,您必須將矢狀單元格分配給Medical3DControl中的SagittalFrame屬性,并且必須將冠狀單元格分配給Medical3DControl的CoronalFrame屬性
該方法InitClass()應(yīng)當(dāng)如下圖所示:
[Visual Basic]
Private Sub InitClass()
                 Dim MY_LICENSE_FILE As String = "d:\temp\TestLic.lic"
                 
                 '開(kāi)啟DICOM支持
                 Dim MY_DicomDEVELOPER_KEY As String = "xyz123abc"
                 RasterSupport.SetLicense(MY_LICENSE_FILE, MY_DicomDEVELOPER_KEY);
                 
                 '開(kāi)啟Medical 支持
                 Dim MY_MedicalDEVELOPER_KEY As String = "abc123xyz"
                 RasterSupport.SetLicense(MY_LICENSE_FILE, MY_MedicalDEVELOPER_KEY);
                 
                 ' 開(kāi)啟Medical 3D支持
                 Dim MY_3DDEVELOPER_KEY As String = "123xyzabc"
                 RasterSupport.SetLicense(MY_LICENSE_FILE, MY_3DDEVELOPER_KEY);
                 
                 //創(chuàng)建一個(gè)可以用于加載圖像的編解碼器類(lèi)的新實(shí)例。
                 RasterCodecs _codecs = new RasterCodecs();
                 //創(chuàng)建一個(gè)Medical查看器的新實(shí)例。其查看器布局將被劃分為2X2。
                 MedicalViewer viewer = new MedicalViewer(2, 2);
                 //使視圖與整個(gè)窗體相匹配
                 viewer.Dock = DockStyle.Fill;
                 //創(chuàng)建一個(gè)包含3D對(duì)象的3D控件。
                 Medical3DControl control3D = new Medical3DControl();
                 control3D.AddAction(MedicalViewerActionType.WindowLevel);
                 control3D.SetAction(MedicalViewerActionType.WindowLevel, MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active);
                 Medical3DObject object3D = new Medical3DObject();
                 //將新創(chuàng)建的3D對(duì)象添加到控件。
                 control3D.ObjectsContainer.Objects.Add(object3D);
                 object3D.Image = _codecs.Load(@"C:\Users\Public\Documents\LEADTOOLS Images\image1.dcm");
                 //將以上的單元格添加到MedicalViewer。
                 viewer.Cells.Add(control3D);
                 Controls.Add(viewer);
                 
                 //創(chuàng)建一個(gè)包含軸向框架的新的單元格。
                 MedicalViewerMPRCell axialCell = new MedicalViewerMPRCell();
                 //調(diào)整其部分屬性以查看十字線。
                 axialCell.ShowMPRCrossHair = true;
                 axialCell.DistinguishMPRByColor = true;
                 
                 //將該單元格(axialCell)分配給Medical3Dcontrol 的AxialFrame屬性。 
                 control3D.AxialFrame = axialCell;
                 
                 //將該軸向單元格添加到查看器。
                 viewer.Cells.Add(axialCell);
                 
                 //創(chuàng)建一個(gè)包含冠狀框架的新單元格。
                 MedicalViewerMPRCell coronalCell = new MedicalViewerMPRCell();
                 
                 //調(diào)整其部分屬性以查看十字線。
                 coronalCell.ShowMPRCrossHair = true;
                 coronalCell.DistinguishMPRByColor = true;
                 
                 // 將該單元格 (coronalCell)分配給Medical3Dcontrol 的CoronalFrame 屬性。
                 control3D.CoronalFrame = coronalCell;
                 
                 viewer.Cells.Add(coronalCell);
                 
                 //創(chuàng)建一個(gè)包含矢狀框架的新單元格。
                 MedicalViewerMPRCell sagittalCell = new MedicalViewerMPRCell();
                 
                 //調(diào)整其部分屬性以查看十字線。
                 sagittalCell.ShowMPRCrossHair = true;
                 sagittalCell.DistinguishMPRByColor = true;
                 
                 //將該單元格(sagittalCell)分配給Medical 3D control的SagittalFrame屬性。
                 control3D.SagittalFrame = sagittalCell;
                 
                 viewer.Cells.Add(sagittalCell);
                 
                 //將該查看器作為子目錄添加到窗體。
                 this.Controls.Add(viewer);
            End Sub
C#
void InitClass()
            {
                 string MY_LICENSE_FILE = "d:\\temp\\TestLic.lic";
               
                 //開(kāi)啟DICOM支持
                 string MY_DicomDEVELOPER_KEY = "xyz123abc";
                 RasterSupport.SetLicense(MY_LICENSE_FILE, MY_DicomDEVELOPER_KEY);
                 
                 //開(kāi)啟Medical 支持
                 string MY_MedicalDEVELOPER_KEY = "abc123xyz";
                 RasterSupport.SetLicense(MY_LICENSE_FILE, MY_MedicalDEVELOPER_KEY);
                 
                 //開(kāi)啟Medical 3D支持
                 string MY_3DDEVELOPER_KEY = "123xyzabc";
                 RasterSupport.SetLicense(MY_LICENSE_FILE, MY_3DDEVELOPER_KEY);
              
                 //創(chuàng)建一個(gè)可以用于加載圖像的編解碼器類(lèi)的新實(shí)例。
                 RasterCodecs _codecs = new RasterCodecs();
                 //創(chuàng)建一個(gè)Medical查看器的新實(shí)例。其查看器布局將被劃分為2X2。
                 MedicalViewer viewer = new MedicalViewer(2, 2);
                 // 使視圖與整個(gè)窗體相匹配
                 viewer.Dock = DockStyle.Fill;
                 //創(chuàng)建一個(gè)包含3D對(duì)象的3D控件。
                 Medical3DControl control3D = new Medical3DControl();
                 control3D.AddAction(MedicalViewerActionType.WindowLevel);
                 control3D.SetAction(MedicalViewerActionType.WindowLevel, MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active);
                 Medical3DObject object3D = new Medical3DObject();
                 //將新創(chuàng)建的3D對(duì)象添加到控件。
                 control3D.ObjectsContainer.Objects.Add(object3D);
                 object3D.Image = _codecs.Load(@"C:\Users\Public\Documents\LEADTOOLS Images\image1.dcm");
                 //將以上的單元格添加到MedicalViewer。
                 viewer.Cells.Add(control3D);
                 Controls.Add(viewer);
              
                 //創(chuàng)建一個(gè)包含軸向框架的新的單元格。
                 MedicalViewerMPRCell axialCell = new MedicalViewerMPRCell();
                 //調(diào)整其部分屬性以查看十字線。
                 axialCell.ShowMPRCrossHair = true;
                 axialCell.DistinguishMPRByColor = true;
              
                 //將該單元格(axialCell)分配給Medical3Dcontrol 的AxialFrame屬性。
                 control3D.AxialFrame = axialCell;
              
                 //將該軸向單元格添加到查看器。
                 viewer.Cells.Add(axialCell);
              
                 //創(chuàng)建一個(gè)包含冠狀框架的新單元格。
                 MedicalViewerMPRCell coronalCell = new MedicalViewerMPRCell();
              
                 //調(diào)整其部分屬性以查看十字線。
                 coronalCell.ShowMPRCrossHair = true;
                 coronalCell.DistinguishMPRByColor = true;
              
                 //將該單元格 (coronalCell)分配給Medical3Dcontrol 的CoronalFrame 屬性。
                 control3D.CoronalFrame = coronalCell;              
                 viewer.Cells.Add(coronalCell);
              
                 //創(chuàng)建一個(gè)包含矢狀框架的新單元格。
                 MedicalViewerMPRCell sagittalCell = new MedicalViewerMPRCell();
              
                 //調(diào)整其部分屬性以查看十字線。
                 sagittalCell.ShowMPRCrossHair = true;
                 sagittalCell.DistinguishMPRByColor = true;
              
                 // 將該單元格(sagittalCell)分配給Medical 3D control的SagittalFrame屬性。 
                 control3D.SagittalFrame = sagittalCell;
              
                 viewer.Cells.Add(sagittalCell);
              
                 //將該查看器作為子目錄添加到窗體。
                 this.Controls.Add(viewer);
             }
最后,請(qǐng)您運(yùn)行該程序。您將能夠看到四個(gè)單元格:一個(gè)適用于3D對(duì)象,另外三個(gè)則分別是軸向單元格,矢狀單元格和冠狀單元格。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@ke049m.cn