Navigation:  Application Architecture > Structure of a ClearCanvas Application > Tools >

Extending Functionality with Tools

Previous pageReturn to chapter overviewNext page

In general, a ClearCanvas application is built up from a number of different application components.  Each component is a self-contained, possibly reusable piece of an application.  As such, a given application component will generally implement some core functionality, which can be considered its intrinsic functionality.

However, an application component may also wish to allow future developers to extend its core functionality by adding additional tools.  In this case, the component must define two things: a tool extension point and a context interface which will provide extension tools with a means of calling back into the application component they are extending.

For example, the desktop defines the extension point DesktopToolExtensionPoint, and the context interface IDeskopToolContext.  Any tool that extends DesktopToolExtensionPoint will be initialized with a reference to an IDesktopToolContext via the ITool.SetContext method. IDesktopToolContext has a property named DesktopWindow, which returns an IDesktopWindow.  Hence, a tool that extends DesktopToolExtensionPoint can perform operations on the IDesktopWindow with which it is associated.

Similarly, the ImageViewerComponent defines the extension point ImageViewerToolExtensionPoint, and the context interface IImageViewerToolContext.  Any tool that extends ImageViewerToolExtensionPoint is initialized with a reference to an IImageViewerToolContext. IImageViewerToolContext has a property named Viewer which returns an IImageViewer, allowing the tool to operate on the IImageViewer with which it is associated.

Note the importance of the context interface in defining the scope of action of a tool.  In this way, the component that defines the tool extension point also decides how much or how little of its core functionality the tool will be able to affect.