Custom components

If you drag a diagram or other unit type from the Projects view into a diagram, a new unit of that type will be added to the diagram. This is called a direct reference to that unit type. Direct references are very convenient and work well in simple cases, but there are some disadvantages to this approach.

CertSAFE automatically generates a default presentation for each directly-referenced unit. The presentation of a unit describes how it looks in the diagram and how you interact with it in the user interface. The default presentation generated by CertSAFE for a direct reference is a simple box with input pins on the left, output pins on the right, and a label in the middle and on each of the pins.

It is possible to configure the size, pin positions, labels, and other attributes of the presentation of a unit by creating a custom component. A custom component consists of three parts:

  • The implementation file, which can be any unit type definition, such as a diagram, stitch, or interpolation table.
  • The presentation file, which specifies all the display and layout information for the component.
  • The component file, which links the presentation and implementation together.
ALT

The presentation editor shows you what the component will look like in a diagram and provides a simple click-and-drag interface for editing the component’s layout. You can edit more advanced properties of the presentation using the pane on the left-hand side of the presentation editor and the Properties view. The component editor simply lets you choose a presentation and implementation to link together.

You can create new blank presentation and component files using the standard File → New menu. However, CertSAFE can also automatically generate default presentation and component files for you. If you right-click on a unit type in the Projects view and select “New Presentation From Existing Unit Type”, CertSAFE will generate an unsaved presentation file that has the same layout that the default presentation for a direct reference to that unit type would have. If you select a single presentation file and a single unit type file in the Projects view, you can right-click and select “New Component From Existing Presentation and Implementation”, which will generate an unsaved component file that has the presentation and implementation fields already filled out for you.

Besides allowing you to change the appearance of a unit to suit your needs, custom components have another advantage over direct references. Since there is an extra layer of indirection between the parent diagram and the child unit type, it is easier to change the implementation of a custom component that is already in use in a project. For example, you can switch a custom component that is implemented as a diagram to use a stitch for its implementation instead without having to modify diagrams that reference it. This is not possible with direct references.