LEADTOOLS Medical (Leadtools.Dicom assembly)

FindFirstGraphicAnnSQItem Method

Show in webframe
Example 







Retrieves the first item under the "Graphic Annotation Sequence" (0070,0001) in the "Graphic Annotation Module".
Syntax
public DicomElement FindFirstGraphicAnnSQItem()
'Declaration
 
Public Function FindFirstGraphicAnnSQItem() As DicomElement
'Usage
 
Dim instance As DicomDataSet
Dim value As DicomElement
 
value = instance.FindFirstGraphicAnnSQItem()
public DicomElement FindFirstGraphicAnnSQItem()

            

            
 function Leadtools.Dicom.DicomDataSet.FindFirstGraphicAnnSQItem()
public:
DicomElement^ FindFirstGraphicAnnSQItem(); 

Return Value

The first item under the "Graphic Annotation Sequence" (0070,0001) in the "Graphic Annotation Module". null if No items were found.
Remarks
This method returns the first item under the "Graphic Annotation Sequence" (0070,0001) in the "Graphic Annotation Module". Call this method along with FindNextGraphicAnnSQItem in order to enumerate all the items under the "Graphic Annotation Sequence" (0070,0001) in the "Graphic Annotation Module".
Example
Copy Code  
Imports Leadtools
Imports Leadtools.Dicom

Public Sub GraphicAnnSequenceSample()
   '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)

      dicomDataset.CreateGraphicAnnSQItem(0, "Layer0")
      Dim firstGraphicAnnSQItem As DicomElement = dicomDataset.FindFirstGraphicAnnSQItem()
      Debug.Assert(Not firstGraphicAnnSQItem Is Nothing)
      'If there was more than one item we can use 
      'FindNextGraphicAnnSQItem to enumerate these items

      dicomDataset.SetLayerName(firstGraphicAnnSQItem, "Layer1")
      Debug.Assert(dicomDataset.GetLayerName(firstGraphicAnnSQItem) = "Layer1")

      ' We can also call RemoveAllImageRefFromAllLayers or call 
      ' RemoveImageRefFromLayer to remove the referenced images one by one.
      ' In any case this is for demonstration purposes only, since the dataset
      ' doesn't have any referenced images right now.
      dicomDataset.RemoveAllImageReferencesFromLayer(firstGraphicAnnSQItem)

      dicomDataset.AddPresentationStateImageReference(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE2.dcm"), Nothing, 0)
      ' We know that the SOP instance UID for the dataset IMAGE2.dcm is
      ' 1.2.840.114257.3.6.5.5.18900282
      dicomDataset.AddLayerImageReference(firstGraphicAnnSQItem, "1.2.840.114257.3.6.5.5.18900282")
      Debug.Assert(dicomDataset.GetLayerImageReferenceCount(firstGraphicAnnSQItem) = 1)
      Debug.Assert(dicomDataset.GetLayerImageReferenceSOPInstance(firstGraphicAnnSQItem, 0) = "1.2.840.114257.3.6.5.5.18900282")
      Debug.Assert(Not dicomDataset.GetLayerImageReferenceElement(firstGraphicAnnSQItem, "1.2.840.114257.3.6.5.5.18900282") Is Nothing)

      '//////This section is for DICOM Graphic Object///////////////////


      Dim graphicObject As DicomGraphicObject = New DicomGraphicObject()
      Dim annotationPoints As DicomAnnotationPoint() = New DicomAnnotationPoint(4) {}
      annotationPoints(0).X = 480.0F
      annotationPoints(0).Y = 226.0F
      annotationPoints(1).X = 480.0F
      annotationPoints(1).Y = 418.0F
      annotationPoints(2).X = 488.0F
      annotationPoints(2).Y = 418.0F
      annotationPoints(3).X = 488.0F
      annotationPoints(3).Y = 226.0F
      annotationPoints(4).X = 480.0F
      annotationPoints(4).Y = 226.0F
      graphicObject.SetAnnotationPoints(annotationPoints, 5)
      graphicObject.Filled = False
      graphicObject.Type = DicomAnnotationType.Polyline
      graphicObject.LayerName = "Layer1"
      graphicObject.Units = DicomAnnotationUnitsRelativityType.Pixel
      Debug.Assert(graphicObject.AnnotationPointCount = 5)

      'Start Clean!
      'Can also call RemoveGraphicObject to remove individual objects
      dicomDataset.RemoveAllGraphicObjects(firstGraphicAnnSQItem)

      dicomDataset.CreateGraphicObject(firstGraphicAnnSQItem, graphicObject, False)
      Debug.Assert(dicomDataset.GetGraphicObjectCount(firstGraphicAnnSQItem) = 1)
      Debug.Assert(Not dicomDataset.GetGraphicObjElement(firstGraphicAnnSQItem, 0) Is Nothing)
      Debug.Assert(dicomDataset.GetGraphicObjPointCount(firstGraphicAnnSQItem, 0) = 5)

      Dim graphicObject1 As DicomGraphicObject = dicomDataset.GetGraphicObjectInformation(firstGraphicAnnSQItem, 0)
      Debug.Assert(Not graphicObject1 Is Nothing)
      graphicObject1.Filled = True
      dicomDataset.SetGraphicObjectInformation(firstGraphicAnnSQItem, 0, graphicObject1)


      '//////This section is for DICOM Text Object///////////////////
      'Can also call RemoveTextObject to remove individual objects
      dicomDataset.RemoveAllTextObjects(firstGraphicAnnSQItem)

      Dim textObject As DicomTextObject = New DicomTextObject()
      textObject.AnchorPointVisible = True
      textObject.AnchorPoint = New DicomAnnotationPoint(1.1F, 1.1F)
      textObject.BRHCorner = New DicomAnnotationPoint(521.251343F, 328.190216F)
      textObject.TLHCorner = New DicomAnnotationPoint(466.642242F, 300.443268F)
      textObject.TextValue = "Text Value 1"
      textObject.AnchorPointUnits = DicomAnnotationUnitsRelativityType.Pixel
      textObject.BoundingBoxUnits = DicomAnnotationUnitsRelativityType.Pixel
      textObject.LayerName = "Layer1"
      textObject.TextJustification = TextAnnotationJustificationType.Left

      dicomDataset.CreateTextObject(firstGraphicAnnSQItem, textObject, False)
      Debug.Assert(dicomDataset.GetTextObjectCount(firstGraphicAnnSQItem) = 1)
      Debug.Assert(Not dicomDataset.GetTextObjElement(firstGraphicAnnSQItem, 0) Is Nothing)

      Dim textObject1 As DicomTextObject = dicomDataset.GetTextObjectInformation(firstGraphicAnnSQItem, 0)
      Debug.Assert(Not textObject1 Is Nothing)
      textObject1.TextJustification = TextAnnotationJustificationType.Right
      dicomDataset.SetTextObjectInformation(firstGraphicAnnSQItem, 0, textObject1)


      dicomDataset.Save(Path.Combine(LEAD_VARS.ImagesDir, "GraphicAnnSequence.dcm"), DicomDataSetSaveFlags.None)
   End Using

   DicomEngine.Shutdown()
End Sub


Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Dicom;

public void GraphicAnnSequenceSample()
{
   //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);

      dicomDataset.CreateGraphicAnnSQItem(0, "Layer0");
      DicomElement firstGraphicAnnSQItem = dicomDataset.FindFirstGraphicAnnSQItem();
      Debug.Assert(firstGraphicAnnSQItem != null);
      //If there was more than one item we can use 
      //FindNextGraphicAnnSQItem to enumerate these items

      dicomDataset.SetLayerName(firstGraphicAnnSQItem, "Layer1");
      Debug.Assert(dicomDataset.GetLayerName(firstGraphicAnnSQItem) == "Layer1");

      // We can also call RemoveAllImageRefFromAllLayers or call 
      // RemoveImageRefFromLayer to remove the referenced images one by one.
      // In any case this is for demonstration purposes only, since the dataset
      // doesn't have any referenced images right now.
      dicomDataset.RemoveAllImageReferencesFromLayer(firstGraphicAnnSQItem);

      dicomDataset.AddPresentationStateImageReference(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE2.dcm"), null, 0);
      // We know that the SOP instance UID for the dataset IMAGE2.dcm is
      // 1.2.840.114257.3.6.5.5.18900282
      dicomDataset.AddLayerImageReference(firstGraphicAnnSQItem, "1.2.840.114257.3.6.5.5.18900282");
      Debug.Assert(dicomDataset.GetLayerImageReferenceCount(firstGraphicAnnSQItem) == 1);
      Debug.Assert(dicomDataset.GetLayerImageReferenceSOPInstance(firstGraphicAnnSQItem, 0) == "1.2.840.114257.3.6.5.5.18900282");
      Debug.Assert(dicomDataset.GetLayerImageReferenceElement(firstGraphicAnnSQItem, "1.2.840.114257.3.6.5.5.18900282") != null);

      ////////This section is for DICOM Graphic Object///////////////////


      DicomGraphicObject graphicObject = new DicomGraphicObject();
      DicomAnnotationPoint[] annotationPoints = new DicomAnnotationPoint[5];
      annotationPoints[0].X = 480.00F;
      annotationPoints[0].Y = 226.00F;
      annotationPoints[1].X = 480.00F;
      annotationPoints[1].Y = 418.00F;
      annotationPoints[2].X = 488.00F;
      annotationPoints[2].Y = 418.00F;
      annotationPoints[3].X = 488.00F;
      annotationPoints[3].Y = 226.00F;
      annotationPoints[4].X = 480.00F;
      annotationPoints[4].Y = 226.00F;
      graphicObject.SetAnnotationPoints(annotationPoints, 5);
      graphicObject.Filled = false;
      graphicObject.Type = DicomAnnotationType.Polyline;
      graphicObject.LayerName = "Layer1";
      graphicObject.Units = DicomAnnotationUnitsRelativityType.Pixel;
      Debug.Assert(graphicObject.AnnotationPointCount == 5);

      //Start Clean!
      //Can also call RemoveGraphicObject to remove individual objects
      dicomDataset.RemoveAllGraphicObjects(firstGraphicAnnSQItem);

      dicomDataset.CreateGraphicObject(firstGraphicAnnSQItem, graphicObject, false);
      Debug.Assert(dicomDataset.GetGraphicObjectCount(firstGraphicAnnSQItem) == 1);
      Debug.Assert(dicomDataset.GetGraphicObjElement(firstGraphicAnnSQItem, 0) != null);
      Debug.Assert(dicomDataset.GetGraphicObjPointCount(firstGraphicAnnSQItem, 0) == 5);

      DicomGraphicObject graphicObject1 = dicomDataset.GetGraphicObjectInformation(firstGraphicAnnSQItem, 0);
      Debug.Assert(graphicObject1 != null);
      graphicObject1.Filled = true;
      dicomDataset.SetGraphicObjectInformation(firstGraphicAnnSQItem, 0, graphicObject1);


      ////////This section is for DICOM Text Object///////////////////
      //Can also call RemoveTextObject to remove individual objects
      dicomDataset.RemoveAllTextObjects(firstGraphicAnnSQItem);

      DicomTextObject textObject = new DicomTextObject();
      textObject.AnchorPointVisible = true;
      textObject.AnchorPoint = new DicomAnnotationPoint(1.1F, 1.1F);
      textObject.BRHCorner = new DicomAnnotationPoint(521.251343F, 328.190216F);
      textObject.TLHCorner = new DicomAnnotationPoint(466.642242F, 300.443268F);
      textObject.TextValue = "Text Value 1";
      textObject.AnchorPointUnits = DicomAnnotationUnitsRelativityType.Pixel;
      textObject.BoundingBoxUnits = DicomAnnotationUnitsRelativityType.Pixel;
      textObject.LayerName = "Layer1";
      textObject.TextJustification = TextAnnotationJustificationType.Left;

      dicomDataset.CreateTextObject(firstGraphicAnnSQItem, textObject, false);
      Debug.Assert(dicomDataset.GetTextObjectCount(firstGraphicAnnSQItem) == 1);
      Debug.Assert(dicomDataset.GetTextObjElement(firstGraphicAnnSQItem, 0) != null);

      DicomTextObject textObject1 = dicomDataset.GetTextObjectInformation(firstGraphicAnnSQItem, 0);
      Debug.Assert(textObject1 != null);
      textObject1.TextJustification = TextAnnotationJustificationType.Right;
      dicomDataset.SetTextObjectInformation(firstGraphicAnnSQItem, 0, textObject1);


      dicomDataset.Save(Path.Combine(LEAD_VARS.ImagesDir, "GraphicAnnSequence.dcm"), DicomDataSetSaveFlags.None);
   }
   DicomEngine.Shutdown();
}


static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
using Leadtools.Dicom.Constants;
using Leadtools;
using Leadtools.Dicom;

      
public async void GraphicAnnSequenceSample()
{
   //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);
      dicomDataset.CreateGraphicAnnSQItem(0, "Layer0");
      DicomElement firstGraphicAnnSQItem = dicomDataset.FindFirstGraphicAnnSQItem();
      Debug.Assert(firstGraphicAnnSQItem != null);
      //If there was more than one item we can use 
      //FindNextGraphicAnnSQItem to enumerate these items

      dicomDataset.SetLayerName(firstGraphicAnnSQItem, "Layer1");
      Debug.Assert(dicomDataset.GetLayerName(firstGraphicAnnSQItem) == "Layer1");

      // We can also call RemoveAllImageRefFromAllLayers or call 
      // RemoveImageRefFromLayer to remove the referenced images one by one.
      // In any case this is for demonstration purposes only, since the dataset
      // doesn't have any referenced images right now.
      dicomDataset.RemoveAllImageReferencesFromLayer(firstGraphicAnnSQItem);

      dicomDataset.AddPresentationStateImageReference(@"ms-appx:///IMAGE3.dcm", null, 0);
      // We know that the SOP instance UID for the dataset IMAGE2.dcm is
      // 1.2.840.114257.3.6.5.5.18900282
      dicomDataset.AddLayerImageReference(firstGraphicAnnSQItem, "1.2.840.114257.3.6.5.5.18900282");
      Debug.Assert(dicomDataset.GetLayerImageReferenceCount(firstGraphicAnnSQItem) == 1);
      Debug.Assert(dicomDataset.GetLayerImageReferenceSOPInstance(firstGraphicAnnSQItem, 0) == "1.2.840.114257.3.6.5.5.18900282");
      Debug.Assert(dicomDataset.GetLayerImageReferenceElement(firstGraphicAnnSQItem, "1.2.840.114257.3.6.5.5.18900282") != null);

      ////////This section is for DICOM Graphic Object///////////////////


      DicomGraphicObject graphicObject = new DicomGraphicObject();
      DicomAnnotationPoint[] annotationPoints = new DicomAnnotationPoint[5];
      annotationPoints[0].X = 480.00F;
      annotationPoints[0].Y = 226.00F;
      annotationPoints[1].X = 480.00F;
      annotationPoints[1].Y = 418.00F;
      annotationPoints[2].X = 488.00F;
      annotationPoints[2].Y = 418.00F;
      annotationPoints[3].X = 488.00F;
      annotationPoints[3].Y = 226.00F;
      annotationPoints[4].X = 480.00F;
      annotationPoints[4].Y = 226.00F;
      graphicObject.SetAnnotationPoints(annotationPoints, 5);
      graphicObject.Filled = false;
      graphicObject.Type = DicomAnnotationType.Polyline;
      graphicObject.LayerName = "Layer1";
      graphicObject.Units = DicomAnnotationUnitsRelativityType.Pixel;
      Debug.Assert(graphicObject.AnnotationPointCount == 5);

      //Start Clean!
      //Can also call RemoveGraphicObject to remove individual objects
      dicomDataset.RemoveAllGraphicObjects(firstGraphicAnnSQItem);

      dicomDataset.CreateGraphicObject(firstGraphicAnnSQItem, graphicObject, false);
      Debug.Assert(dicomDataset.GetGraphicObjectCount(firstGraphicAnnSQItem) == 1);
      Debug.Assert(dicomDataset.GetGraphicObjElement(firstGraphicAnnSQItem, 0) != null);
      Debug.Assert(dicomDataset.GetGraphicObjPointCount(firstGraphicAnnSQItem, 0) == 5);

      DicomGraphicObject graphicObject1 = dicomDataset.GetGraphicObjectInformation(firstGraphicAnnSQItem, 0);
      Debug.Assert(graphicObject1 != null);
      graphicObject1.Filled = true;
      dicomDataset.SetGraphicObjectInformation(firstGraphicAnnSQItem, 0, graphicObject1);


      ////////This section is for DICOM Text Object///////////////////
      //Can also call RemoveTextObject to remove individual objects
      dicomDataset.RemoveAllTextObjects(firstGraphicAnnSQItem);

      DicomTextObject textObject = new DicomTextObject();
      textObject.AnchorPointVisible = true;
      textObject.AnchorPoint = DicomAnnotationPointHelper.Create(1.1F, 1.1F);
      textObject.BRHCorner = DicomAnnotationPointHelper.Create(521.251343F, 328.190216F);
      textObject.TLHCorner = DicomAnnotationPointHelper.Create(466.642242F, 300.443268F);
      textObject.TextValue = "Text Value 1";
      textObject.AnchorPointUnits = DicomAnnotationUnitsRelativityType.Pixel;
      textObject.BoundingBoxUnits = DicomAnnotationUnitsRelativityType.Pixel;
      textObject.LayerName = "Layer1";
      textObject.TextJustification = TextAnnotationJustificationType.Left;

      dicomDataset.CreateTextObject(firstGraphicAnnSQItem, textObject, false);
      Debug.Assert(dicomDataset.GetTextObjectCount(firstGraphicAnnSQItem) == 1);
      Debug.Assert(dicomDataset.GetTextObjElement(firstGraphicAnnSQItem, 0) != null);

      DicomTextObject textObject1 = dicomDataset.GetTextObjectInformation(firstGraphicAnnSQItem, 0);
      Debug.Assert(textObject1 != null);
      textObject1.TextJustification = TextAnnotationJustificationType.Right;
      dicomDataset.SetTextObjectInformation(firstGraphicAnnSQItem, 0, textObject1);


      string dicomFileNameOutput = "GraphicAnnSequence.dcm";
      StorageFile saveFile = await Tools.AppLocalFolder.CreateFileAsync(dicomFileNameOutput);
      ILeadStream streamOutput = LeadStreamFactory.Create(saveFile);
      using (IDisposable disposableOUT = streamOutput as IDisposable)
      {
         await dicomDataset.SaveAsync(streamOutput, DicomDataSetSaveFlags.None);
      }
   }
   DicomEngine.Shutdown();
}
using Leadtools;
using Leadtools.Dicom;
using Leadtools.Examples;

public void GraphicAnnSequenceSample(Stream outputStream)
{
   //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);
      dicomDataset.CreateGraphicAnnSQItem(0, "Layer0");
      DicomElement firstGraphicAnnSQItem = dicomDataset.FindFirstGraphicAnnSQItem();
      Debug.Assert(firstGraphicAnnSQItem != null);
      //If there was more than one item we can use 
      //FindNextGraphicAnnSQItem to enumerate these items

      dicomDataset.SetLayerName(firstGraphicAnnSQItem, "Layer1");
      Debug.Assert(dicomDataset.GetLayerName(firstGraphicAnnSQItem) == "Layer1");

      // We can also call RemoveAllImageRefFromAllLayers or call 
      // RemoveImageRefFromLayer to remove the referenced images one by one.
      // In any case this is for demonstration purposes only, since the dataset
      // doesn't have any referenced images right now.
      dicomDataset.RemoveAllImageReferencesFromLayer(firstGraphicAnnSQItem);

      dicomDataset.AddPresentationStateImageReference(SampleDicomFile.Get(SampleDicomFileNames.Image2_dcm), null, 0);
      // We know that the SOP instance UID for the dataset IMAGE2.dic is
      // 1.2.840.114257.3.6.5.5.18900282
      dicomDataset.AddLayerImageReference(firstGraphicAnnSQItem, "1.2.840.114257.3.6.5.5.18900282");
      Debug.Assert(dicomDataset.GetLayerImageReferenceCount(firstGraphicAnnSQItem) == 1);
      Debug.Assert(dicomDataset.GetLayerImageReferenceSOPInstance(firstGraphicAnnSQItem, 0) == "1.2.840.114257.3.6.5.5.18900282");
      Debug.Assert(dicomDataset.GetLayerImageReferenceElement(firstGraphicAnnSQItem, "1.2.840.114257.3.6.5.5.18900282") != null);

      ////////This section is for DICOM Graphic Object///////////////////


      DicomGraphicObject graphicObject = new DicomGraphicObject();
      DicomAnnotationPoint[] annotationPoints = new DicomAnnotationPoint[5];
      annotationPoints[0].X = 480.00F;
      annotationPoints[0].Y = 226.00F;
      annotationPoints[1].X = 480.00F;
      annotationPoints[1].Y = 418.00F;
      annotationPoints[2].X = 488.00F;
      annotationPoints[2].Y = 418.00F;
      annotationPoints[3].X = 488.00F;
      annotationPoints[3].Y = 226.00F;
      annotationPoints[4].X = 480.00F;
      annotationPoints[4].Y = 226.00F;
      graphicObject.SetAnnotationPoints(annotationPoints, 5);
      graphicObject.Filled = false;
      graphicObject.Type = DicomAnnotationType.Polyline;
      graphicObject.LayerName = "Layer1";
      graphicObject.Units = DicomAnnotationUnitsRelativityType.Pixel;
      Debug.Assert(graphicObject.AnnotationPointCount == 5);

      //Start Clean!
      //Can also call RemoveGraphicObject to remove individual objects
      dicomDataset.RemoveAllGraphicObjects(firstGraphicAnnSQItem);

      dicomDataset.CreateGraphicObject(firstGraphicAnnSQItem, graphicObject, false);
      Debug.Assert(dicomDataset.GetGraphicObjectCount(firstGraphicAnnSQItem) == 1);
      Debug.Assert(dicomDataset.GetGraphicObjElement(firstGraphicAnnSQItem, 0) != null);
      Debug.Assert(dicomDataset.GetGraphicObjPointCount(firstGraphicAnnSQItem, 0) == 5);

      DicomGraphicObject graphicObject1 = dicomDataset.GetGraphicObjectInformation(firstGraphicAnnSQItem, 0);
      Debug.Assert(graphicObject1 != null);
      graphicObject1.Filled = true;
      dicomDataset.SetGraphicObjectInformation(firstGraphicAnnSQItem, 0, graphicObject1);


      ////////This section is for DICOM Text Object///////////////////
      //Can also call RemoveTextObject to remove individual objects
      dicomDataset.RemoveAllTextObjects(firstGraphicAnnSQItem);

      DicomTextObject textObject = new DicomTextObject();
      textObject.AnchorPointVisible = true;
      textObject.AnchorPoint = new DicomAnnotationPoint(1.1F, 1.1F);
      textObject.BRHCorner = new DicomAnnotationPoint(521.251343F, 328.190216F);
      textObject.TLHCorner = new DicomAnnotationPoint(466.642242F, 300.443268F);
      textObject.TextValue = "Text Value 1";
      textObject.AnchorPointUnits = DicomAnnotationUnitsRelativityType.Pixel;
      textObject.BoundingBoxUnits = DicomAnnotationUnitsRelativityType.Pixel;
      textObject.LayerName = "Layer1";
      textObject.TextJustification = TextAnnotationJustificationType.Left;

      dicomDataset.CreateTextObject(firstGraphicAnnSQItem, textObject, false);
      Debug.Assert(dicomDataset.GetTextObjectCount(firstGraphicAnnSQItem) == 1);
      Debug.Assert(dicomDataset.GetTextObjElement(firstGraphicAnnSQItem, 0) != null);

      DicomTextObject textObject1 = dicomDataset.GetTextObjectInformation(firstGraphicAnnSQItem, 0);
      Debug.Assert(textObject1 != null);
      textObject1.TextJustification = TextAnnotationJustificationType.Right;
      dicomDataset.SetTextObjectInformation(firstGraphicAnnSQItem, 0, textObject1);


      dicomDataset.Save(outputStream, DicomDataSetSaveFlags.None);
   }
   DicomEngine.Shutdown();
}
Imports Leadtools
Imports Leadtools.Dicom

Public Sub GraphicAnnSequenceSample(ByVal outputStream As Stream)
   'Make sure to initialize the DICOM engine, this needs to be done only once 
   'In the whole application
   DicomEngine.Startup()
   Using dicomDataset As DicomDataSet = New DicomDataSet()
      ' We can also initialize in here the "Grayscale Softcopy Presentation State" class
      dicomDataset.Initialize(DicomClassType.Undefined, DicomDataSetInitializeType.ExplicitVRLittleEndian)
      dicomDataset.CreateGraphicAnnSQItem(0, "Layer0")
      Dim firstGraphicAnnSQItem As DicomElement = dicomDataset.FindFirstGraphicAnnSQItem()
      Debug.Assert(Not firstGraphicAnnSQItem Is Nothing)
      'If there was more than one item we can use 
      'FindNextGraphicAnnSQItem to enumerate these items

      dicomDataset.SetLayerName(firstGraphicAnnSQItem, "Layer1")
      Debug.Assert(dicomDataset.GetLayerName(firstGraphicAnnSQItem) = "Layer1")

      ' We can also call RemoveAllImageRefFromAllLayers or call 
      ' RemoveImageRefFromLayer to remove the referenced images one by one.
      ' In any case this is for demonstration purposes only, since the dataset
      ' doesn't have any referenced images right now.
      dicomDataset.RemoveAllImageReferencesFromLayer(firstGraphicAnnSQItem)

      dicomDataset.AddPresentationStateImageReference(SampleDicomFile.Get(SampleDicomFileNames.Image2_dcm), Nothing, 0)
      ' We know that the SOP instance UID for the dataset IMAGE2.dic is
      ' 1.2.840.114257.3.6.5.5.18900282
      dicomDataset.AddLayerImageReference(firstGraphicAnnSQItem, "1.2.840.114257.3.6.5.5.18900282")
      Debug.Assert(dicomDataset.GetLayerImageReferenceCount(firstGraphicAnnSQItem) = 1)
      Debug.Assert(dicomDataset.GetLayerImageReferenceSOPInstance(firstGraphicAnnSQItem, 0) = "1.2.840.114257.3.6.5.5.18900282")
      Debug.Assert(Not dicomDataset.GetLayerImageReferenceElement(firstGraphicAnnSQItem, "1.2.840.114257.3.6.5.5.18900282") Is Nothing)

      '//////This section is for DICOM Graphic Object///////////////////


      Dim graphicObject As DicomGraphicObject = New DicomGraphicObject()
      Dim annotationPoints As DicomAnnotationPoint() = New DicomAnnotationPoint(4){}
      annotationPoints(0).X = 480.00F
      annotationPoints(0).Y = 226.00F
      annotationPoints(1).X = 480.00F
      annotationPoints(1).Y = 418.00F
      annotationPoints(2).X = 488.00F
      annotationPoints(2).Y = 418.00F
      annotationPoints(3).X = 488.00F
      annotationPoints(3).Y = 226.00F
      annotationPoints(4).X = 480.00F
      annotationPoints(4).Y = 226.00F
      graphicObject.SetAnnotationPoints(annotationPoints, 5)
      graphicObject.Filled = False
      graphicObject.Type = DicomAnnotationType.Polyline
      graphicObject.LayerName = "Layer1"
      graphicObject.Units = DicomAnnotationUnitsRelativityType.Pixel
      Debug.Assert(graphicObject.AnnotationPointCount = 5)

      'Start Clean!
      'Can also call RemoveGraphicObject to remove individual objects
      dicomDataset.RemoveAllGraphicObjects(firstGraphicAnnSQItem)

      dicomDataset.CreateGraphicObject(firstGraphicAnnSQItem, graphicObject, False)
      Debug.Assert(dicomDataset.GetGraphicObjectCount(firstGraphicAnnSQItem) = 1)
      Debug.Assert(Not dicomDataset.GetGraphicObjElement(firstGraphicAnnSQItem, 0) Is Nothing)
      Debug.Assert(dicomDataset.GetGraphicObjPointCount(firstGraphicAnnSQItem, 0) = 5)

      Dim graphicObject1 As DicomGraphicObject = dicomDataset.GetGraphicObjectInformation(firstGraphicAnnSQItem, 0)
      Debug.Assert(Not graphicObject1 Is Nothing)
      graphicObject1.Filled = True
      dicomDataset.SetGraphicObjectInformation(firstGraphicAnnSQItem, 0, graphicObject1)


      '//////This section is for DICOM Text Object///////////////////
      'Can also call RemoveTextObject to remove individual objects
      dicomDataset.RemoveAllTextObjects(firstGraphicAnnSQItem)

      Dim textObject As DicomTextObject = New DicomTextObject()
      textObject.AnchorPointVisible = True
      textObject.AnchorPoint = New DicomAnnotationPoint(1.1F, 1.1F)
      textObject.BRHCorner = New DicomAnnotationPoint(521.251343F, 328.190216F)
      textObject.TLHCorner = New DicomAnnotationPoint(466.642242F, 300.443268F)
      textObject.TextValue = "Text Value 1"
      textObject.AnchorPointUnits = DicomAnnotationUnitsRelativityType.Pixel
      textObject.BoundingBoxUnits = DicomAnnotationUnitsRelativityType.Pixel
      textObject.LayerName = "Layer1"
      textObject.TextJustification = TextAnnotationJustificationType.Left

      dicomDataset.CreateTextObject(firstGraphicAnnSQItem, textObject, False)
      Debug.Assert(dicomDataset.GetTextObjectCount(firstGraphicAnnSQItem) = 1)
      Debug.Assert(Not dicomDataset.GetTextObjElement(firstGraphicAnnSQItem, 0) Is Nothing)

      Dim textObject1 As DicomTextObject = dicomDataset.GetTextObjectInformation(firstGraphicAnnSQItem, 0)
      Debug.Assert(Not textObject1 Is Nothing)
      textObject1.TextJustification = TextAnnotationJustificationType.Right
      dicomDataset.SetTextObjectInformation(firstGraphicAnnSQItem, 0, textObject1)


      dicomDataset.Save(outputStream, DicomDataSetSaveFlags.None)
   End Using
   DicomEngine.Shutdown()
End Sub
Requirements

Target Platforms

See Also

Reference

DicomDataSet Class
DicomDataSet Members
FindNextGraphicAnnSQItem Method
GetLayerName Method
SetLayerName Method
CreateGraphicAnnSQItem Method
AddLayerImageReference Method
GetLayerImageReferenceCount Method
RemoveImageReferenceFromLayer Method
RemoveAllImageReferencesFromLayer Method
RemoveAllImageReferences Method
GetLayerImageReferenceElement Method

 

 


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

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