Navigation:  I Want To... > Imaging >

Add a new DisplaySet

Previous pageReturn to chapter overviewNext page

Use Case

You want to create a new DisplaySet.

Relevant Architecture

Physical and Logical Workspaces

Relevant Types

IDisplaySet
IImageSet

Sample Code

using System;

using ClearCanvas.Common;

using ClearCanvas.Desktop;

using ClearCanvas.Desktop.Actions;

using ClearCanvas.Dicom;

using ClearCanvas.ImageViewer;

using ClearCanvas.ImageViewer.BaseTools;

 

// ... (other using namespace statements here)

 

namespace MyPlugin.Imaging

{

   [ButtonAction("apply""global-toolbars/ToolbarStandard/AddDisplaySetTool""Apply")]

   [IconSet("apply", IconScheme.Colour, "Icons.MyToolSmall.png""Icons.MyToolMedium.png""Icons.MyToolLarge.png")]

   // ... (other action attributes here)

   [ExtensionOf(typeof (ImageViewerToolExtensionPoint))]

   public class AddDisplaySetTool : ImageViewerTool

   {

      public void Apply()

      {

         if (this.ImageViewer == null)

            return;

 

         if (this.ImageViewer.SelectedImageBox == null)

            return;

 

         // Create volume from currently selected DisplaySet

 

         // in this case, we'll need to use the VolumePresentationImage

         // in the ClearCanvas.ImageViewer.Tools.Volume.VTK project

         IDisplaySet selectedDisplaySet = this.ImageViewer.SelectedImageBox.DisplaySet;

         VolumePresentationImage image = new VolumePresentationImage(selectedDisplaySet);

 

         // Create new DisplaySet   

         IDisplaySet displaySet = new DisplaySet(

            String.Format("{0} (3D)", selectedDisplaySet.Name),

            DicomUid.GenerateUid().ToString());

 

         // Add the VolumePresentationImage

         displaySet.PresentationImages.Add(image);

         this.ImageViewer.LogicalWorkspace.ImageSets[0].DisplaySets.Add(displaySet);

 

         // Put DisplaySet in ImageBox and render

         IImageBox imageBox = this.ImageViewer.SelectedImageBox;

         imageBox.DisplaySet = displaySet;

         imageBox.Draw();

      }

   }

}

Remarks

Other than laying out images for the first time, you will typically want to create a new DisplaySet when there are new PresentationImages you want to display. The sample above shows how you might display a 3D volume rendering represented by a VolumePresentationImage.  Note that if you want the new DisplaySet to appear in the ImageViewerComponent's context menu, you must add it to the LogicalWorkspace.

Examples in Code Base

ClearCanvas.ImageViewer.Layout.Basic.LayoutManager
ClearCanvas.ImageViewer.Tools.Volume.VTK.VolumeComponent