LEADTOOLS Medical
LEAD Technologies, Inc

DefaultObject Property

Example 





Gets or sets the defaults used when calling ToAnnObject. .NET support Silverlight support
Syntax
public object DefaultObject {get; set;}
'Declaration
 
Public Property DefaultObject As Object
'Usage
 
Dim instance As DicomAnnotationsUtilities
Dim value As Object
 
instance.DefaultObject = value
 
value = instance.DefaultObject
public object DefaultObject {get; set;}
 get_DefaultObject();
set_DefaultObject(value);
public:
property Object^ DefaultObject {
   Object^ get();
   void set (    Object^ value);
}

Property Value

Contains defaults that are used when when calling ToAnnObject.
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
Example
 
Public Sub DicomDataSet_FromAnnObjectToDataSet(ByVal outfile As String)
      ' Create a dataset
   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
public void DicomDataSet_FromAnnObjectToDataSet(string outfile)
{
   DicomEngine.Startup();
   // Create a dataset
   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();
}
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);
}
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
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

DicomAnnotationsUtilities Class
DicomAnnotationsUtilities Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.

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