The Graphics (

) form object can plot the same thing as you can plot in the
Graphics window in the COMSOL Desktop. Typically, you choose a plot group under the
Results branch of the model to plot. You can also plot a geometry or mesh, or dynamically let the plot type change. In addition, you can include the plot-while-solving functionality (including probe plots) in runnable applications. To do so, enable it in the study step settings and then ensure that the plot group you are plotting is set as the source to the Graphics form object.
The Zoom to extents on first plot check box is selected by default. This setting makes the first plot that appears in the graphics canvas zoom to its extents when the applications starts, if the graphics canvas is empty initially or when something is plotted the first time. Clear this check box to disable the zoom to extents action.
Select the Data picking check box to activate data picking in the Graphics window. The data picking provides functionality for processing user interaction with the Graphics form object.
The Settings window contains the following sections.
In this section, you specify a node that represents a plot that becomes the initial contents of the graphics window. The section contains a tree with a filtered view of the trees in the Application Builder and
Model Builder windows. The nodes represent some sort of plot or have children that do. The filtered view also includes Explicit selection nodes. You can extend the list of available data nodes by clicking the
Switch to Model Builder and Activate Data Access button (

) in the
Source for Initial Graphics Content section header, which takes you to the Model Builder, and then selecting a node in the
Model Builder branch whose data you want to access. With this button active, the
Settings window of the selected node displays a
Select Data Source check box (a green square) next to the settings that you can include. Click to select the check box to include the data as an available source node for graphics objects.
When you select a node that represents data, the Use as Source button (

) below the tree becomes enabled. You can click it or, alternatively, press Enter, double-click, or right-click the node and choose
Use as Source to add it as the selected source. After selecting a node as the source, the node appears as the selected source under
Selected source. You can select from all plot groups and player animations under the
Results branch and all geometry and mesh nodes. You can also select
Explicit selection nodes, which makes it possible for users to select geometric entities to update that selection directly in the graphics. Alternatively, use a
Selection Input object in the application for activating selections of geometric entities. Click the
Edit Node toolbar button (

) below the tree to move to the corresponding node. If necessary, the program switches to the Model Builder. Click the
Clear Source toolbar button (

) to remove a source that you have selected.
You can also select a string under the Declarations branch. The value of this string controls the plot to show, where the value represents a path to one of the nodes that you can select. For example, if the value is
pg1, the plot shows the plot group with this tag. If the value is
/GeomList/geom1, it plots the geometry with the tag
geom1, and
/MeshList/mesh1 plots the mesh with the tag
mesh1. You can also use the value
/Results/ResultFeatureList/pg1 for the plot group, but that syntax is rather cumbersome.
When you have selected the Data picking check box above, select a valid data picking target from the list in this section. The target could be a declared double floating point variable, which then is used in a form to display some quantity at the clicked location in the graphics window. The list also contains probes defined in the model and
Graphics Data nodes added under
Declarations (see
The Graphics Data Node). For a probe, you can, for example, use a slider to let the user of the application determine the depth along a line in a 3D geometry. Using a
Graphics Data node, you can output both the clicked location and some evaluated result at that location. You can also click the
Create New Declaration and Use It as Source button (

) or the
Create New Form Declaration and Use It as Source button (

) in the
Target for Data Picking section header to create a new global or local (in the form) variable declaration for the data picking and use it as the selected target. A
Create and Use Declaration dialog box opens so that you can select the data type of the target (if applicable), its name, and its initial value (if applicable). You can extend the list of available data nodes by clicking the
Switch to Model Builder and Activate Data Access button (

).
Click the Use as Target button (

) to make the selected node the target for the data picking. That node then appears under
Selected target. Click the
Edit Node button (

) to move to the
Settings window for the selected node in the tree.
To add an icon to the upper-right corner (a logo, for example), specify an image file to use from the Icon list, which includes all images in the
Images library, or click the
Add Image to Library and Use Here button (

) to locate an image to use on the file system. This image becomes a part of the
Images library and is selected as the icon in this
Graphics object. If you do not want to use an icon, select
None from the
Icon list. Click the
Export button (

) to export the image to the file system (for use in another application, for example).
This section also contains settings for the background color. Under Background for 2D plots, use the
Color list to select the background color for 2D plots and 1D graphs. The 3D background supports a gradient from top to bottom. Under
Background for 3D plots, choose the top and bottom color in the
Top color and
Bottom color lists.
For all plot background colors, Use default is the default setting. This setting is a white background for 2D plots and 1D graphs, and a light blue gradient for 3D plots. In addition to a set of predefined colors, you can also choose
Transparent and
Custom. For
Custom, choose a color from the color palette that appears.
Under State, you can control the initial state of the graphics object when users run the application. By default, the graphics object is visible and enabled. Clear the
Visible or
Enabled check box if you want to make the initial state so that the graphics object is hidden or unavailable. You can then make it visible or enable it using a method. In the Form Editor, the state of the form object is indicated by a change in its appearance. Objects that are hidden become visible when selected in the Form Editor.
From the Position list, choose where you want to position the toolbar relative to the table:
Below,
Above (the default),
Left, or
Right.
You can choose from two icon sizes: From the Icon size list, choose
Small (the default) or
Large.
For the background color of the toolbar, choose a color from the Background color list.
White is the default background color. In addition to a set of predefined colors, you can also choose
Transparent and
Custom. For
Custom, choose a color from the color palette that appears.
Under Standard toolbar, you can control the layout of the standard toolbar groups and which of them to include.
From the Include standard toolbar items list, you can choose
Default,
None, or
Custom:
•
|
Select None if you do not want to display the standard plot toolbar buttons for zooming, changing the view, showing legends, adding scene light and transparency, and for creating image snapshots and printing the plot.
|
-
|
Choose Hidden to remove the group of toolbar items.
|
-
|
Choose Compact to use one menu button for all actions in the group.
|
-
|
Choose Normal to use the default group layout for the group.
|
-
|
Choose Wide to display all menu items in the group, when applicable.
|
By default, the toolbar items that you add are placed before the standard toolbar. Clear the Place standard toolbar before custom items check box to place the custom items after the standard toolbar items.
In the table under Custom toolbar items, you can add one or more buttons to form a custom plot toolbar:
•
|
Click the Add Separator button (  ) to add a separator between groups of buttons in the toolbar.
|
Select a button in the table and click the Edit button (

) if you want to change the appearance or behavior of a custom toolbar button in the
Edit Custom Toolbar Item dialog box. Click the
Move Up and
Move Down buttons (

and

) to move and rearrange the toolbar button order. Click the
Delete button (

) to delete the selected button.
The table contains a row for each added item, showing its name, icon, text, and tooltip in the Name,
Icon,
Text, and
Tooltip columns, respectively. In the leftmost column, an error symbol (

) or a warning symbol (

) appears to indicate a warning or error in the added item. For example, an error symbol appears for a toggle item that is missing a source.
•
|
From the Horizontal alignment list, choose Left, Center, Right, or Fill, which automatically expands the form object to fill the cell in the horizontal or vertical direction (where applicable).
|
•
|
From the Vertical alignment list, choose Middle, Top, Bottom, or Fill, which automatically expands the form object to fill the cell in the horizontal or vertical direction (where applicable).
|
The need to specify the alignment is most obvious when working in the grid mode, as it controls how the form object is aligned in its grid cell. Aligning the form object can be useful in the sketch mode too, and you can then use the alignment tools on the Arrange menu in the
Form toolbar’s
Sketch section. When running the application in any client other than the Windows client, the form objects may not be positioned exactly as seen in the form windows. This is because the form objects may have a different size in other clients, giving them a slightly different positioning. Specifying the alignment ensures that the form objects are aligned as you want them to be in all clients.
You can also specify the width and height of the graphics object. Enter a width (in points) in the Width field and a height (in points) in the
Height field. If you have chosen
Fill from the
Horizontal alignment list, you can instead specify a
Minimum width. Choose
Automatic to compute the minimum width automatically (typically this means a minimum size of 0), or choose
Manual to specify a minimum width in the text field underneath. If you have chosen
Fill from the
Vertical alignment list, you can instead specify a
Minimum height. Choose
Automatic to compute the minimum height automatically (typically this means a minimum size of 0), or choose
Manual to specify a minimum height in the text field underneath.
Additionally, in the sketch mode, you can specify the form object’s absolute position using the Position x and
Position y fields. In the grid mode, you can position the object in the grid and see the grid position as the
Row,
Column,
Row span, and
Column span values.
Under Cell margin (in grid mode only), you can control the margins around the form object. By default, the margins are taken from the parent form. From the
Cell margin list, choose:
•
|
None, for no margin around the form object.
|
•
|
Custom, to specify the margins for the form object in the Horizontal and Vertical text fields.
|
You can specify a method or command sequence to run when a picking change occurs in the Graphics object. The On picking changed list contains
None (the default) and any available methods or command sequence. You can add the following types of events by choosing from the
Create Global Method menu (

) to the right of the
On data change list:
•
|
Choose Create Global Method (  ) to create a global method. Type the name of the global method in the Name field of the Create Global Method dialog box that opens and then click OK. The global method is then added under Methods, and its Method Editor window opens.
|
•
|
Choose Create Form Method (  ) to create a form method. Type the name of the form method in the Name field of the Create Form Method dialog box that opens and then click OK. The form method is then added under the Methods node under the Form node, and its Method Editor window opens.
|
•
|
Choose Create Local Method (  ) to create a local method. Its Method Editor window opens.
|
•
|
Choose Create Command Sequence (  ) to create a command sequence using the Create Command Sequence dialog box that opens. There you can choose commands from the available Forms, GUI Commands, Declarations, Form Declarations, Methods, Form Methods, Libraries, and Model folders. To add a command, right-click the desired command node and choose the command to use ( Run, for example). The command then appears in the list of commands below. You can edit that command sequence using the toolbar buttons for moving and deleting commands below the table. Click the Convert to Method button (  ) and choose Convert to Method or Convert to Form Method to convert the command sequence to a method. Click the Go to Method button (  ) below the table to select the method in the Application Builder tree and open the method in a Method Editor window. For commands that include arguments, click the Edit Argument button (  ) to choose an argument in the Edit Argument dialog box that opens.
|
There can only be one local method and one command sequence so if you add one or both of them, the menu will instead contain Remove Local Method (

) and
Remove Command Sequence (

), respectively. Click one of them to delete the local method or command sequence.
The selected method in the On picking changed list then changes to the created method or command sequence. To open the selected method or command sequence, click the
Go to Source button (

). The focus then moves to the method’s editor window or the
Command Sequence dialog box, respectively.