Leadtools.Dicom Requires Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.10.31
CreateLayer Method
See Also  Example
Leadtools.Dicom Namespace > DicomDataSet Class : CreateLayer Method




graphicLayer
A Graphic Layer attributes , which holds the attributes of the layer to be created.
Adds a new item under the "Graphic Layer Sequence" (0070,0060) in the Graphic Layer Module".

Syntax

Visual Basic (Declaration) 
Public Function CreateLayer( _
   ByVal graphicLayer As DicomGraphicLayer _
) As Integer
Visual Basic (Usage)Copy Code
Dim instance As DicomDataSet
Dim graphicLayer As DicomGraphicLayer
Dim value As Integer
 
value = instance.CreateLayer(graphicLayer)
C# 
public int CreateLayer( 
   DicomGraphicLayer graphicLayer
)
Managed Extensions for C++ 
public: int CreateLayer( 
   DicomGraphicLayer* graphicLayer
) 
C++/CLI 
public:
int CreateLayer( 
   DicomGraphicLayer^ graphicLayer
) 

Parameters

graphicLayer
A Graphic Layer attributes , which holds the attributes of the layer to be created.

Return Value

The index of the newly created layer.

Example

This example will initialize a new DICOM dataset, insert a new layer with one graphic object and one text object.

Visual BasicCopy Code
Public Sub DicomLayerSample()
    'Make sure to initialize the DICOM engine, this needs to be done only once
    'In the whole application
    DicomEngine.Startup()

    Dim dicomDataset As DicomDataSet = New DicomDataSet()
      Using (dicomDataset)
         ' We can also initialize in here the "Grayscale Softcopy Presentation State" class
         dicomDataset.Initialize(DicomClassType.Undefined, DicomDataSetInitializeType.ExplicitVRLittleEndian)

         'We can remove individual layers by calling RemoveLayerByIndex and RemoveLayerByName
         dicomDataset.RemoveAllLayers(True)

         Dim graphicLayer As DicomGraphicLayer = New DicomGraphicLayer()

         graphicLayer.LayerOrder = 1
         graphicLayer.LayerDescription = "First Layer"
         graphicLayer.LayerName = "LAYER0"
         graphicLayer.Grayscale = 0
         graphicLayer.RgbLayerColor = 255

         dicomDataset.CreateLayer(graphicLayer)

         Debug.Assert(dicomDataset.GetLayerIndex("LAYER0") = 0)

         Dim graphicLayer1 As DicomGraphicLayer = dicomDataset.GetLayerInformation(0)
         Debug.Assert(Not graphicLayer1 Is Nothing)
         Debug.Assert(graphicLayer1.LayerOrder = 1)

         graphicLayer.LayerName = "LAYER1"
         dicomDataset.SetLayerInformation(0, graphicLayer)

         Debug.Assert(dicomDataset.LayerCount = 1)

         ' We can also call GetLayerElementByName to get the layer elemnt
         Dim layer As DicomElement = dicomDataset.GetLayerElementByIndex(0)
         Debug.Assert(Not layer Is Nothing)

         dicomDataset.RemoveLayerGraphicObjects(layer)
         Debug.Assert(dicomDataset.GetLayerGraphicObjectCount(layer) = 0)

         dicomDataset.RemoveLayerTextObjects(layer)
         Debug.Assert(dicomDataset.GetLayerTextObjectCount(layer) = 0)

         dicomDataset.Save("C:\PresentationState.dic", DicomDataSetSaveFlags.None)
      End Using

      DicomEngine.Shutdown()
   End Sub
C#Copy Code
public void DicomLayerSample() 

   //Make sure to initialize the DICOM engine, this needs to be done only once  
   //In the whole application 
   DicomEngine.Startup(); 
   using (DicomDataSet dicomDataset = new DicomDataSet()) 
   { 
      // We can also initialize in here the "Grayscale Softcopy Presentation State" class 
      dicomDataset.Initialize(DicomClassType.Undefined, DicomDataSetInitializeType.ExplicitVRLittleEndian); 
 
      //We can remove individual layers by calling RemoveLayerByIndex and RemoveLayerByName 
      dicomDataset.RemoveAllLayers(true); 
 
      DicomGraphicLayer graphicLayer = new DicomGraphicLayer(); 
 
      graphicLayer.LayerOrder = 1; 
      graphicLayer.LayerDescription = "First Layer"; 
      graphicLayer.LayerName = "LAYER0"; 
      graphicLayer.Grayscale = 0; 
      graphicLayer.RgbLayerColor =255; 
 
      dicomDataset.CreateLayer(graphicLayer); 
 
      Debug.Assert(dicomDataset.GetLayerIndex("LAYER0") ==0); 
 
      DicomGraphicLayer graphicLayer1 = dicomDataset.GetLayerInformation(0); 
      Debug.Assert(graphicLayer1 != null); 
      Debug.Assert(graphicLayer1.LayerOrder == 1); 
 
      graphicLayer.LayerName = "LAYER1"; 
      dicomDataset.SetLayerInformation(0, graphicLayer); 
 
      Debug.Assert(dicomDataset.LayerCount == 1); 
 
      //  We can also call GetLayerElementByName to get the layer elemnt 
      DicomElement layer = dicomDataset.GetLayerElementByIndex(0); 
      Debug.Assert(layer != null); 
 
      dicomDataset.RemoveLayerGraphicObjects(layer); 
      Debug.Assert(dicomDataset.GetLayerGraphicObjectCount(layer)==0); 
 
      dicomDataset.RemoveLayerTextObjects(layer); 
      Debug.Assert(dicomDataset.GetLayerTextObjectCount(layer) == 0); 
 
      dicomDataset.Save(@"C:\PresentationState.dic", DicomDataSetSaveFlags.None); 
   } 
   DicomEngine.Shutdown(); 
}

Remarks

If for example there are already 2 items under the "Graphic Layer Sequence" (0070,0060) and we call this method, then the index of the new layer will be 2.

This method will fail and throw a DicomExceptionCode.Parameter exception if a layer with the same name as the new layer already exists in the Data Set.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

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