LEADTOOLS Medical (Leadtools.Dicom.Annotations assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
DefaultObject Property
See Also 
Leadtools.Dicom.Annotations Namespace > DicomAnnotationsUtilities Class : DefaultObject Property



The DefaultObject Property is available in LEADTOOLS Medical Imaging toolkits.

Gets or sets the defaults used when calling ToAnnObject. Supported in Silverlight, Windows Phone 7

Syntax

Visual Basic (Declaration) 
Public Property DefaultObject As Object
Visual Basic (Usage)Copy Code
Dim instance As DicomAnnotationsUtilities
Dim value As Object
 
instance.DefaultObject = value
 
value = instance.DefaultObject
C# 
public object DefaultObject {get; set;}
C++/CLI 
public:
property Object^ DefaultObject {
   Object^ get();
   void set (    Object^ value);
}

Property Value

Contains defaults that are used when when calling ToAnnObject.

Example

This sample does the following:

  1. Creates a rectangle annotation object.
  2. Creates Leadtools.Dicom.DicomDataSet that is type GrayscaleSoftcopyPresentationState that will hold the annotations.
  3. Creates a converter
  4. Converts LEAD annotation to DICOM annotations, and automatically saves in the Leadtools.Dicom.DicomDataSet

Visual BasicCopy Code
Public Sub DicomDataSet_FromAnnObjectToDataSet(ByVal outfile As String)
   ' Create a datset
   Dim ds As New DicomDataSet()
   ds.Initialize(DicomClassType.GrayscaleSoftcopyPresentationState, DicomDataSetInitializeFlags.AddMandatoryElementsOnly Or DicomDataSetInitializeFlags.AddMandatoryModulesOnly)
   ' Create an AnnRectangleObject
   Dim annObject As New AnnRectangleObject()
   annObject.Pen = New AnnPen(Color.Purple, New AnnLength(5))

   annObject.Brush = New AnnSolidBrush(Color.White)
   annObject.Bounds = New AnnRectangle(400, 100, 100, 100)

   ' Save in the dataset as DICOM annotation
   Dim element As DicomElement = ds.FindFirstElement(Nothing, DicomTag.GraphicAnnotationSequence, True)
   If Nothing Is element Then
      element = ds.InsertElement(Nothing, False, DicomTag.GraphicAnnotationSequence, DicomVRType.SQ, True, 0)
   End If

   Dim itemElement As DicomElement = ds.GetChildElement(element, True)
   If Nothing Is itemElement Then
      ' Add Item Node
      itemElement = ds.InsertElement(element, True, DicomTag.Item, DicomVRType.CS, True, -1)
      If Nothing Is itemElement Then
         Return
      End If

      ds.InsertElement(itemElement, True, DicomTag.TextObjectSequence, DicomVRType.SQ, True, -1)
      ds.InsertElement(itemElement, True, DicomTag.GraphicObjectSequence, DicomVRType.SQ, True, -1)
      ds.InsertElement(itemElement, True, DicomTag.ReferencedImageSequence, DicomVRType.SQ, True, -1)
      ds.InsertElement(itemElement, True, DicomTag.GraphicLayer, DicomVRType.CS, False, -1)
      If Nothing IsNot element Then
         ds.SetStringValue(element, "LEAD OBJECTS LAYER", DicomCharacterSetType.Default)
      End If

      ' Add graphic layer
      Dim GraphicLayer As New DicomGraphicLayer()

      GraphicLayer.LayerOrder = 1
      GraphicLayer.RgbLayerColor = 0 ' null
      GraphicLayer.LayerDescription = "Layer for LEAD objects"
      GraphicLayer.LayerName = "LEAD OBJECTS LAYER"
      GraphicLayer.Grayscale = 65535
      Dim index As Integer = ds.CreateLayer(GraphicLayer)
   End If

   Dim du As New DicomAnnotationsUtilities()
   du.FromAnnObjectToDataSet(ds, annObject, itemElement)
   ds.Save(outfile, DicomDataSetSaveFlags.None)
End Sub
C#Copy Code
public void DicomDataSet_FromAnnObjectToDataSet(string outfile)
{
   DicomEngine.Startup();
   // Create a datset
   DicomDataSet ds = new DicomDataSet();
   ds.Initialize(DicomClassType.GrayscaleSoftcopyPresentationState, DicomDataSetInitializeFlags.AddMandatoryElementsOnly | DicomDataSetInitializeFlags.AddMandatoryModulesOnly);
   // Create an AnnRectangleObject
   AnnRectangleObject annObject = new AnnRectangleObject();
   annObject.Pen = new AnnPen(Color.Purple, new AnnLength(5));

   annObject.Brush = new AnnSolidBrush(Color.White);
   annObject.Bounds = new AnnRectangle(400, 100, 100, 100);

   // Save in the dataset as DICOM annotation
   DicomElement element = ds.FindFirstElement(null, DicomTag.GraphicAnnotationSequence, true);
   if (null == element)
   {
      element = ds.InsertElement(null, false, DicomTag.GraphicAnnotationSequence, DicomVRType.SQ, true, 0);
   }

   DicomElement itemElement = ds.GetChildElement(element, true);
   if (null == itemElement)
   {
      // Add Item Node
      itemElement = ds.InsertElement(element, true, DicomTag.Item, DicomVRType.CS, true, -1);
      if (null == itemElement)
         return;

      ds.InsertElement(itemElement, true, DicomTag.TextObjectSequence, DicomVRType.SQ, true, -1);
      ds.InsertElement(itemElement, true, DicomTag.GraphicObjectSequence, DicomVRType.SQ, true, -1);
      ds.InsertElement(itemElement, true, DicomTag.ReferencedImageSequence, DicomVRType.SQ, true, -1);
      ds.InsertElement(itemElement, true, DicomTag.GraphicLayer, DicomVRType.CS, false, -1);
      if (null != element)
      {
         ds.SetStringValue(element, "LEAD OBJECTS LAYER", DicomCharacterSetType.Default);
      }

      // Add graphic layer
      DicomGraphicLayer GraphicLayer = new DicomGraphicLayer();

      GraphicLayer.LayerOrder = 1;
      GraphicLayer.RgbLayerColor = 0; // null
      GraphicLayer.LayerDescription = "Layer for LEAD objects";
      GraphicLayer.LayerName = "LEAD OBJECTS LAYER";
      GraphicLayer.Grayscale = 65535;
      int index = ds.CreateLayer(GraphicLayer);
   }

   DicomAnnotationsUtilities du = new DicomAnnotationsUtilities();
   du.FromAnnObjectToDataSet(ds, annObject, itemElement);
   ds.Save(outfile, DicomDataSetSaveFlags.None);

   DicomEngine.Shutdown();
}
SilverlightCSharpCopy Code
public void DicomDataSet_FromAnnObjectToDataSet(Stream outputStream)
{
   // Create a datset
   DicomDataSet ds = new DicomDataSet();
   ds.Initialize(DicomClassType.GrayscaleSoftcopyPresentationState, DicomDataSetInitializeFlags.AddMandatoryElementsOnly | DicomDataSetInitializeFlags.AddMandatoryModulesOnly);
   // Create an AnnRectangleObject
   AnnRectangleObject annObject = new AnnRectangleObject();
   annObject.Stroke = Color.FromArgb(0xFF, 0x80, 0x00, 0x80); // purple
   annObject.StrokeThickness = 5;

   annObject.Fill = Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF); // white
   annObject.Rect = new Rect(400, 100, 500, 200);

   // Save in the dataset as DICOM annotation
   DicomElement element = ds.FindFirstElement(null, DicomTag.GraphicAnnotationSequence, true);
   if (null == element)
   {
      element = ds.InsertElement(null, false, DicomTag.GraphicAnnotationSequence, DicomVRType.SQ, true, 0);
   }

   DicomElement itemElement = ds.GetChildElement(element, true);
   if (null == itemElement)
   {
      // Add Item Node
      itemElement = ds.InsertElement(element, true, DicomTag.Item, DicomVRType.CS, true, -1);
      if (null == itemElement)
         return;

      ds.InsertElement(itemElement, true, DicomTag.TextObjectSequence, DicomVRType.SQ, true, -1);
      ds.InsertElement(itemElement, true, DicomTag.GraphicObjectSequence, DicomVRType.SQ, true, -1);
      ds.InsertElement(itemElement, true, DicomTag.ReferencedImageSequence, DicomVRType.SQ, true, -1);
      ds.InsertElement(itemElement, true, DicomTag.GraphicLayer, DicomVRType.CS, false, -1);
      if (null != element)
      {
         ds.SetStringValue(element, "LEAD OBJECTS LAYER", DicomCharacterSetType.Default);
      }

      // Add graphic layer
      DicomGraphicLayer GraphicLayer = new DicomGraphicLayer();

      GraphicLayer.LayerOrder = 1;
      GraphicLayer.RgbLayerColor = 0; // null
      GraphicLayer.LayerDescription = "Layer for LEAD objects";
      GraphicLayer.LayerName = "LEAD OBJECTS LAYER";
      GraphicLayer.Grayscale = 65535;
      int index = ds.CreateLayer(GraphicLayer);
   }

   DicomAnnotationsUtilities du = new DicomAnnotationsUtilities();
   du.FromAnnObjectToDataSet(ds, annObject, itemElement);
   ds.Save(outputStream, DicomDataSetSaveFlags.None);
}
SilverlightVBCopy Code
Public Sub DicomDataSet_FromAnnObjectToDataSet(ByVal outputStream As Stream)
   ' Create a datset
   Dim ds As DicomDataSet = New DicomDataSet()
   ds.Initialize(DicomClassType.GrayscaleSoftcopyPresentationState, DicomDataSetInitializeFlags.AddMandatoryElementsOnly Or DicomDataSetInitializeFlags.AddMandatoryModulesOnly)
   ' Create an AnnRectangleObject
   Dim annObject As AnnRectangleObject = New AnnRectangleObject()
   annObject.Stroke = Color.FromArgb(&HFF, &H80, &H00, &H80) ' purple
   annObject.StrokeThickness = 5

   annObject.Fill = Color.FromArgb(&HFF, &HFF, &HFF, &HFF) ' white
   annObject.Rect = New Rect(400, 100, 500, 200)

   ' Save in the dataset as DICOM annotation
   Dim element As DicomElement = ds.FindFirstElement(Nothing, DicomTag.GraphicAnnotationSequence, True)
   If Nothing Is element Then
      element = ds.InsertElement(Nothing, False, DicomTag.GraphicAnnotationSequence, DicomVRType.SQ, True, 0)
   End If

   Dim itemElement As DicomElement = ds.GetChildElement(element, True)
   If Nothing Is itemElement Then
      ' Add Item Node
      itemElement = ds.InsertElement(element, True, DicomTag.Item, DicomVRType.CS, True, -1)
      If Nothing Is itemElement Then
         Return
      End If

      ds.InsertElement(itemElement, True, DicomTag.TextObjectSequence, DicomVRType.SQ, True, -1)
      ds.InsertElement(itemElement, True, DicomTag.GraphicObjectSequence, DicomVRType.SQ, True, -1)
      ds.InsertElement(itemElement, True, DicomTag.ReferencedImageSequence, DicomVRType.SQ, True, -1)
      ds.InsertElement(itemElement, True, DicomTag.GraphicLayer, DicomVRType.CS, False, -1)
      If Not Nothing Is element Then
         ds.SetStringValue(element, "LEAD OBJECTS LAYER", DicomCharacterSetType.Default)
      End If

      ' Add graphic layer
      Dim GraphicLayer As DicomGraphicLayer = New DicomGraphicLayer()

      GraphicLayer.LayerOrder = 1
      GraphicLayer.RgbLayerColor = 0 ' null
      GraphicLayer.LayerDescription = "Layer for LEAD objects"
      GraphicLayer.LayerName = "LEAD OBJECTS LAYER"
      GraphicLayer.Grayscale = 65535
      Dim index As Integer = ds.CreateLayer(GraphicLayer)
   End If

   Dim du As DicomAnnotationsUtilities = New DicomAnnotationsUtilities()
   du.FromAnnObjectToDataSet(ds, annObject, itemElement)
   ds.Save(outputStream, DicomDataSetSaveFlags.None)
End Sub

Remarks

A Leadtools.Dicom.DicomAnnotationObject can be filled, however it doesn't have fill color, pen color, text color or a font. An Leadtools.Annotations.AnnObject can have a fill color, a pen color, a text color, and a font. When calling ToAnnObject to convert a Leadtools.Dicom.DicomAnnotationObject, the DefaultObject is an AnnObject that is referenced when setting the default values.

Note: for Silverlight users, the System.Object is of type Leadtools.Windows.Annotations.AnnObject

Requirements

Target Platforms: Silverlight 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)

See Also

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