Model Center—Component Browser
The component browser on the right-hand side of the model editor lists all components of the currently open class in a tree view. The components are grouped with respect to the class in which they are declared. Base classes in the component browser are recognized by the "extends" prefix before their name.
Components and classes with no declared components appear as leaves in the tree view, while components and classes containing components are represented as branches. To expand a component or class, click the symbol to the left of its icon (or name if no icon is available). Clicking the symbol of an expanded component or class will collapse it again.
The tree view has two columns where the first column shows the icon (if available) and the name of the class or component, while the second column shows the component type for components and the full hierarchical name for classes. The second column showing type information is not visible by default. See the section Sorting and Column Visibility on how to toggle the visibility of the columns.
The components of the Modelica.Mechanics.Rotational.Examples.CoupledClutches model.
Sorting and Column Visibility
By default, the component browser shows only the Name column, with items sorted by component name in ascending order, indicated by an arrow in the column header. Clicking the header reverses the direction.
A second column showing component types can be revealed by right-clicking the column header and selecting Type from the popup menu. Once visible, clicking the Type column header sorts the items by type, with a second click reversing the direction.
Toggling the visibility of component browser columns.
Right-clicking an empty area of the component browser brings up a popup menu with an Arrange by submenu offering a shortcut that combines both settings. Choosing Name sorts by name; choosing Type sorts by type and also makes the Type column visible if it was hidden. The currently active arrangement is indicated by a check mark.
Selecting Components
The Component Browser allows any number of items to be selected. Select a single item by clicking it once with the left mouse button. Additional items can be selected by clicking them while holding down the Control key. To select a range of items, click the first item and then the last item while holding down the Shift key.
When selecting a component (or even multiple components as long as their types are the same), the variable views are populated with the component's parameters, variables and constants, allowing you to configure the component.
By selecting an item representing a base class (an item starting with the word extends followed by a class name), it is possible to show only the parameters, variables and constants inherited from that specific class in the variable views.
Opening and Editing Classes
The base classes and the classes of components listed in the component browser can be edited by right-clicking a class or component and choosing Open Class from the popup menu. The class will be opened in a new class window unless already open.
Opening Components
Double-clicking a component, or right-clicking it and choosing Open Component from the popup menu, allows you visualize the internals of the component graphically. Refer to the section on visualizing component hierarchies for how this can be valuable in understanding and configuring a model.
Renaming Components
A component can be renamed from the Component Browser or from the graphical views (Icon View or Diagram View) if present, by right-clicking it and choosing Rename from the popup menu. It is also possible to rename a component by selecting it and pressing the F2 key. Components that appear in any of the variable views can also be renamed from that view: just click the name of the component and chose Rename from the popup menu.
When renaming a component, all references to the renamed component within its own library are updated automatically. Other non-read-only libraries, using the library of the renamed component, are listed in the dialog. By default, references to the component in these libraries are also updated, unless a library is explicitly unchecked.
A library LibraryA, is considered to be using the library LibraryB Version 1.0 if it contains the following annotation: uses(LibraryB(version="1.0")). A uses annotation is automatically inserted into a library by System Modeler when an operation is performed that makes one library dependent on another, for instance, when dropping a component from one library onto a model in another. The only requirement is that the library from which the component was dropped has a declared version. See this section for more information on how to view and edit the version or dependencies (uses annotations) of a library.
Renaming a component named m within the library Modelica, updating references to the component in all libraries that are using Modelica.
When the renaming operation is completed, a list of all classes that were modified (if any) due to references to the renamed component is shown.
Note that it is not possible to rename a component using the Component Browser, graphical views or variable views while editing a class in the Modelica Text View, nor is it possible to rename an inherited component.
Removing Components
The component browser can also be used to remove components from a class. First, make sure that the active view of the class window is either the Icon View or the Diagram View. Select the component(s) to remove and choose Edit ▶ Delete or right-click the component's name and choose Delete from the popup menu. Note that it is not possible to delete individual inherited components, nor is it possible to delete components while editing a class in the Modelica Text View.
To remove all components inherited from a specific extended class, you can remove the inheritance relationship by selecting the extended class in the component browser and deleting it. For more information, see the section on removing inheritance relationships.
Removing Inheritance Relationships
The component browser groups components with regard to their declaration class, making it easy to see from what class components are inherited. By selecting an extended class in the component browser and choosing Edit ▶ Delete, the inheritance relationship can be removed. The class will be removed from the list of extended classes, causing all components inherited from that class to be removed.
The list of extended classes can also be edited from the Class Properties dialog box, where you may also add classes; see the section on editing class properties.
Note that it is not possible to remove an inheritance relationship using the component browser while editing a class in the Modelica Text View.
Editing Properties of Components
The properties of a component can be edited by right-clicking the component and choosing Properties from the popup menu or by selecting the component and choosing Properties from the Edit menu.
For more information on the Component Properties dialog box, see this section. Note that it is not possible to edit the properties of a component using the Component Properties dialog box while the Modelica Text View is active.
Making Components Final
To prevent a component from being further modified, it can be made final. It is still possible to modify the component in the class in which it is made made final, but not from any class creating a component of that class or extending that class.
To make a variable final, right-click the component. In the menu that is shown, click final to toggle its final property. A check mark to the left of final is an indication that it has been made final. If the component is present on one of the graphical views (Icon View or Diagram View), the final property can also be toggled from there.
Sometimes the final item is disabled and cannot be clicked. This can happen, for instance, when a component is part of another component that has been made final, making all components inside that component implicitly final as well.
Changing the Type of Components
The type of an existing component can be changed. If the component is declared in the class of the active class window, its type can be changed by right-clicking the component in the Component Browser (or Diagram View if the component is present there) and choosing Change Component Type... from the popup menu. Changing the type this way substitutes the declared type of the component in the class definition, affecting all classes extending the class or using it as a component.
In the dialog box that is shown, enter the new type of the component and click OK. It is also possible to drag a class from the Class Browser and drop it in the text box.
Changing the type of a component.
Another way of changing a type is by redeclaring the component. This is possible when a component is declared as replaceable (by default, components are not replaceable). For information on how to redeclare a component, see the section Redeclaring and Configuring Replaceable Components.
Providing a Set of Candidate Components for Component Redeclarations
If you develop a model with replaceable components, you may want to provide a customized list of components for the user to choose from when a component is redeclared. This can be done using the choices annotation, which is a standard Modelica annotation.
If, for instance, you have an electrical model of a main board with a CPU, you can make the CPU replaceable and introduce a choices annotation with configurations of pin-compatible processors, making it possible for a user of the main board to easily test the main board with different processors. The choices annotation will be an annotation for the CPU component in the main board model.
replaceable Electrical.MC68000 cpu annotation(
choices(
choice(redeclare Computer.MC68000 cpu(freq=8)
"Motorola 68000 at 8MHz"),
choice(redeclare Computer.MC68000 cpu(freq=16)
"Motorola 68000 at 16MHz"),
choice(redeclare Computer.MC68010 cpu(freq=16)
"Motorola 68010 at 16MHz")
), Placement(...)));
In the preceding example, three candidates are provided for the redeclaration: an MC68000 CPU at 8MHz, an MC68000 CPU at 16MHz and an MC68010 CPU at 16MHz. When the user adds the main board as a component in their computer model, changing the CPU becomes a matter of right-clicking the CPU, choosing Redeclare from the menu, and then selecting the new processor from a list of candidates. As can be seen in the screenshot following, the strings in the choices annotation represent the candidates when redeclaring the CPU component.
Choices annotations for components can also be created and edited using the Component Properties dialog. For more information, see the section Choices for Component Redeclarations in the Reusable and Configurable Models tutorial.
Redeclaring a component with a choices annotation.
Adding Graphical Representations for Components
When adding a component to a class in the Modelica Text View, you may notice that the component does not appear in the Diagram View unless you specify a graphical annotation for it. The graphical annotation describes the placement of the component in the Diagram View, and for connector components, also their placement in the Icon View.
The model editor can generate a graphical annotation for a component if you drag the component from the component browser and drop it in the Diagram View. If the component is a connector component, it will also appear in the Icon View.
Graphical annotations for several components can be generated at once by dragging a selection of components from the component browser and dropping them in the Diagram View. The components will then be laid out in a grid.
Graphical annotations for existing connections will also be generated, if missing, when graphical annotations for connected components are generated.