Graphical Icons (.svg)
Icons for the graphical interface are stored in the Scalable Vector Graphics format. A good tool, which is free and open-source, for creating and editing such files is Inkscape. If you want to use bitmaps graphics, .jpg, .png or similar formats, such graphics can be embedded in a .svg file.
Inkscape Webpage
Appearance Description Files (.xml)
Information about the component for the graphical interface, such as icon, port positions and component name, is stored in a .xml file. This file contains information about the component that is not part of the actual simulation code. This information can be changed without the need to recompile the actual component code. A typical appearance file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<hopsanobjectappearance version="0.3">
<modelobject typename="HydraulicLaminarOrifice" subtypename="Orifice1" displayname="Laminar Orifice">
<icons>
<icon type="iso" path="laminarorifice_iso.svg" iconrotation="ON" scale="1.0"/>
<icon type="user" path="laminarorifice_user.svg" iconrotation="ON" scale="1.0"/>
</icons>
<help>
<text>Help Text</text>
<picture>helpPicture.svg</picture>
<link>externalHelpDocumentation.pdf</link>
<html>./HydraulicLaminarOrifice.html</html>
<md>./HydraulicLaminarOrifice.md</md>
</help>
<ports>
<port name="P1" x="1.0" y="0.5" a="0" visible="true"/>
<port name="P2" x="0.0" y="0.5" a="180" visible="true"/>
<port name="Kc" x="0.5" y="0.0" a="270" visible="false"/>
</ports>
<parametersets>
<parameterset name="First parameter set" path="firstparameterset.ssv"/>
<parameterset name="Second parameter set" path="secondparameterset.ssv"/>
</parametersets>
</modelobject>
</hopsanobjectappearance>
The first line contains basic information about the XML code, and should always look the same. A description of the remaining tags follows:
- hopsanobjectappearance Main tag for appearance file
- version Should always be 0.3 with this XML layout
- modelobject Main tag for the component
- typename Name of the component as registered in the simulation core, see The Component Library Source File. (Required)
- subtypename Specific version of a typename component, if you have multiple appearance files for the same component code. (Optional)
- displayname Name for the component shown in the graphical interface. (If omitted typename will be used)
- icons Contains information about icons. At least one type, user or iso is required.
- type The icon type, user or iso (ISO 1219)
- path Relative path from the .xml file to the .svg
- iconrotation Tells whether the icon rotates when the component is rotated in the workspace
- scale Lets you adjust the scale of the .svg graphics (without modifying the actual .svg file) (default=1.0 if omitted)
- help Allows you to specify help information explaining the function of the component. (Optional)
- text The help text. (Optional)
- picture The path to the .svg help picture. (Optional)
- link Link to external document (relative this xml file) or URL, you can have multiple links
- html External html help document
- md External markdown file (will generate html on-the-fly, including LaTeX equation support) Note! You can have either html or markdown, not both!
- ports Defines the positions and orientations for each port (Required for each port)
- name Name of the port as defined in the code
- x X-position fraction of component icon width (0 = left, 1 = right)
- y Y-position fraction of component icon height (0 = top, 1 = bottom)
- a Angle of port, 0 = right, 90 = down, 180 = left, 270 = up, ports shall normally point outwards from the component
- visible If the port is visible by default, true or false. (If omitted defaults to true)
- parametersets Defines available pre-defined parameter sets for the component in System Structure Parameter Values format
- name Name of each parameter set
- path Relative path from the .xml file to the parameter set (.ssv)