opticalMaterialPicker
Description
Add-On Required: This feature requires the Optical Design and Simulation Library for Image Processing Toolbox add-on.
Use the optical material picker UI component to pick glass materials
interactively. For more information about the interactions that the optical material picker UI
component enables, see Optical Material Picker Interactions. Properties of the
OpticalMaterialPicker object control the appearance and behavior of the UI
component. By changing property values, you can manage controls for selecting optical glass
materials for optical systems.
Creation
You can create a OpticalMaterialPicker object using the
opticalMaterialPicker function.
Description
creates an
optical material picker in a new figure window. The UI component enables you to browse,
filter, and select optical glass materials from the glass library and MATLAB® workspace. You can use the optical material picker within the Optical System
Designer app or integrate the picker in your own custom apps.picker = opticalMaterialPicker
sets writable properties of the optical material picker UI component using one or more
optional name-value arguments. By specifying properties of the
picker = opticalMaterialPicker(PropertyName=Value)OpticalMaterialPicker object, you can configure the UI component to
filter glass materials based on refractive index, Abbe number, wavelength support, and
material name. You can also control the appearance and behavior of the UI
component.
Output Arguments
Optical material picker UI component, returned as an
OpticalMaterialPicker object.
Properties
Optical Material Filters
Refractive index range, specified as a 2-element vector.
Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
Abbe number range, specified as a 2-element vector.
Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
Wavelength range in nanometers, specified as a 2-element vector. The default
wavelength range is the optimal wavelength range to accommodate the visible spectrum
of electromagnetic waves. The WavelengthRange filter ensures that
the picker retains only those materials that support all wavelengths in the specified
range.
Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
Hint for the glass material name, specified as a string scalar or character
vector. If you specify GlassNameHint as three or fewer characters,
the picker filters for the glass materials with names that include the specified
string, regardless of case. If you specify a hint of more than three characters, the
picker uses an edit-distance metric to filter similarly named glass materials.
Data Types: char | string
Selected optical glass material, specified as an
opticalMaterial object. By default, the picker selects the first
glass material of the first catalog listed in the Catalog and
Glass List of the UI. If no glass materials exist in the filtered list,
the picker selects vacuum by default.
Position
UI component size and location excluding the margins, specified as a 4-element
vector of the form [left bottom width height]. The values of
left and bottom specify the location of the
lower-left corner of the UI component, and width and
height specify its dimensions in the x- and
y-directions, respectively. By default, MATLAB measures the values in units normalized to the container. To change the
units, set the Units property.
This property is read-only.
Inner size and location, represented as a 4-element vector of the form
[left bottom width height]. This property is equivalent to the
Position property.
Size and location including the labels and margin, specified as a 4-element vector
of the form [left bottom width height]. The values of
left and bottom specify the location of the
lower-left corner of the UI component, and width and
height specify its dimensions in the x- and
y-directions, respectively. By default, MATLAB measures the values in units normalized to the container. To change the
units, set the Units property.
Units of measurement, specified as one of these options.
Units Value | Description |
|---|---|
"normalized" (default) | Normalized with respect to the container, which is typically a figure or
panel. The lower-left corner of the container maps to (0,
0) and the upper-right corner maps to (1,
1). |
"inches" | Inches. |
"centimeters" | Centimeters. |
"characters" | Based on the default
|
"points" | Typography points. One point equals 1/72 inch. |
"pixels" | Pixels. On Windows® and Macintosh systems, the size of a pixel is 1/96 inch. This size is independent of your system resolution. On Linux® systems, the size of a pixel is determined by your system resolution. |
Layout options, specified as a GridLayoutOptions object. This
property specifies options for components that are children of grid layout containers.
If the component is not a child of a grid layout container (for example, it is a child
of a figure or panel), then this property is empty and has no effect. However, if the
component is a child of a grid layout container, you can place the component in the
intended row and column of the grid by setting the Row and
Column properties of the GridLayoutOptions
object.
For example, this code places an optical material picker in the third row and second column of its parent grid.
g = uigridlayout([4 3]); picker = opticalMaterialPicker(Parent=g); picker.Layout.Row = 3; picker.Layout.Column = 2;
Color and Styling
Background color, specified as an RGB triplet, a hexadecimal color code, or one of the color options listed in the table.
| Color Name | Short Name | RGB Triplet | Hexadecimal Color Code | Appearance |
|---|---|---|---|---|
"red" | "r" | [1 0 0] | "#FF0000" |
|
"green" | "g" | [0 1 0] | "#00FF00" |
|
"blue" | "b" | [0 0 1] | "#0000FF" |
|
"cyan"
| "c" | [0 1 1] | "#00FFFF" |
|
"magenta" | "m" | [1 0 1] | "#FF00FF" |
|
"yellow" | "y" | [1 1 0] | "#FFFF00" |
|
"black" | "k" | [0 0 0] | "#000000" |
|
"white" | "w" | [1 1 1] | "#FFFFFF" |
|
Interactivity
State of visibility, specified as "on" or
"off", or as numeric or logical 1
(true) or 0 (false). A
value of "on" is equivalent to true, and
"off" is equivalent to false. Thus, you can
use the value of this property as a logical value. The value is stored as an on/off
logical value of type matlab.lang.OnOffSwitchState.
"on"— Display the object."off"— Hide the object without deleting it. You can still access the properties of an invisible UI component.
To make your app start faster, set the Visible property to
"off" for all components that do not need to appear at
startup.
Changing the size of an invisible container triggers the
SizeChangedFcn callback when it becomes visible.
Changing the Visible property of a container does
not change the values of the Visible
properties of child components. This is true even though hiding the container causes
the child components to be hidden.
Context menu, specified as a ContextMenu object created using
the uicontextmenu function. Use this
property to display a context menu when you right-click on an area of the component
that does not contain any underlying UI components or graphics objects.
To display a context menu when you right-click on any portion of the custom UI
component, write code to set the ContextMenu property of all
underlying UI components and graphics objects whenever the
ContextMenu property of your custom component is set.
Callbacks
Size change callback, specified as one of these values:
Function handle.
Cell array in which the first element is a function handle. Subsequent elements in the cell array are the arguments to pass to the callback function.
Character vector containing a valid MATLAB expression (not recommended). MATLAB evaluates this expression in the base workspace.
For more information about specifying a callback as a function handle, cell array, or character vector, see Callbacks in App Designer.
The SizeChangedFcn callback executes when:
The component becomes visible for the first time.
The component is visible while its size changes.
This component becomes visible for the first time after its size changes. This situation occurs when the size changes while the component is invisible, and then it becomes visible later.
Object creation function, specified as one of these values:
Function handle.
Cell array in which the first element is a function handle. Subsequent elements in the cell array are the arguments to pass to the callback function.
Character vector containing a valid MATLAB expression (not recommended). MATLAB evaluates this expression in the base workspace.
For more information about specifying a callback as a function handle, cell array, or character vector, see Callbacks in App Designer.
This property specifies a callback function to execute when MATLAB creates the object. MATLAB initializes all property values before executing the
CreateFcn callback. If you do not specify the
CreateFcn property, then MATLAB executes a default creation function.
Setting the CreateFcn property on an existing component has
no effect.
If you specify this property as a function handle or cell array, you can access
the object that is being created using the first argument of the callback function.
Otherwise, use the gcbo function to access the
object.
Object deletion function, specified as one of these values:
Function handle.
Cell array in which the first element is a function handle. Subsequent elements in the cell array are the arguments to pass to the callback function.
Character vector containing a valid MATLAB expression (not recommended). MATLAB evaluates this expression in the base workspace.
For more information about specifying a callback as a function handle, cell array, or character vector, see Callbacks in App Designer.
This property specifies a callback function to execute when MATLAB deletes the object. MATLAB executes the DeleteFcn callback before destroying
the properties of the object. If you do not specify the DeleteFcn
property, then MATLAB executes a default deletion function.
If you specify this property as a function handle or cell array, you can access
the object that is being deleted using the first argument of the callback function.
Otherwise, use the gcbo function to access the
object.
Button down callback, specified as one of these values:
Function handle.
Cell array in which the first element is a function handle. Subsequent elements in the cell array are the arguments to pass to the callback function.
Character vector containing a valid MATLAB expression (not recommended). MATLAB evaluates this expression in the base workspace.
For more information about specifying a callback as a function handle, cell array, or character vector, see Callbacks in App Designer.
The ButtonDownFcn callback executes when you click the
OpticalMaterialPicker object.
Callback Execution Control
Callback interruption, specified as "on" or
"off", or as numeric or logical 1
(true) or 0 (false). A
value of "on" is equivalent to true, and
"off" is equivalent to false. Thus, you can
use the value of this property as a logical value. The value is stored as an on/off
logical value of type matlab.lang.OnOffSwitchState.
This property determines if a running callback can be interrupted. There are two callback states to consider:
The running callback is the currently executing callback.
The interrupting callback is a callback that tries to interrupt the running callback.
Whenever MATLAB invokes a callback while another callback is running, the newly invoked
callback attempts to interrupt the running callback. The
Interruptible property of the object that owns the running
callback determines if interruption is allowed.
A value of
"on"allows other callbacks to interrupt the callbacks of the object. The interruption occurs at the next point where MATLAB processes the queue, such as when there is adrawnow,figure,uifigure,getframe,waitfor, orpausecommand.If the running callback contains one of those commands, then MATLAB stops the execution of the callback at that point and executes the interrupting callback. MATLAB resumes executing the running callback when the interrupting callback completes.
If the running callback does not contain one of those commands, then MATLAB finishes executing the callback without interruption.
A value of
"off"blocks all interruption attempts. TheBusyActionproperty of the object that owns the interrupting callback determines if the interrupting callback is discarded or put into a queue.
Note
Callback interruption and execution behave differently in these situations:
If the interrupting callback is a
DeleteFcnorSizeChangedFcncallback, then the interruption occurs regardless of theInterruptibleproperty value.If the running callback is currently executing the
waitforfunction, then the interruption occurs regardless of theInterruptibleproperty value.Timerobjects execute according to schedule regardless of theInterruptibleproperty value.
When an interruption occurs, MATLAB does not save the state of properties or the display. For example, the
object returned by the gca or gcf command might change when another callback executes.
Callback queuing, specified as "queue" or
"cancel". The BusyAction property determines
how MATLAB handles the execution of interrupting callbacks. There are two callback
states to consider:
The running callback is the currently executing callback.
The interrupting callback is a callback that tries to interrupt the running callback.
Whenever MATLAB invokes a callback while another callback is running, the newly invoked
callback attempts to interrupt the running callback. The
Interruptible property of the object that owns the running
callback determines if interruption is permitted. If interruption is not permitted,
then the BusyAction property of the object that owns the
interrupting callback determines if it is discarded or put in the queue. These are the
possible values of the BusyAction property:
"queue"— Puts the interrupting callback in a queue to be processed after the running callback finishes execution."cancel"— Does not execute the interrupting callback.
This property is read-only.
Deletion status, represented as an on/off logical value of type matlab.lang.OnOffSwitchState.
MATLAB sets the BeingDeleted property to
"on" when the DeleteFcn callback begins
execution. The BeingDeleted property remains set to
"on" until the component object no longer exists.
Before querying or modifying an object, check the value of the
BeingDeleted property of the object to verify that it is not
about to be deleted
Parent/Child
Parent container, specified as a Figure, Panel,
Tab, or GridLayout object. By default, the parent
container is a new Figure object.
UI component children, returned as an empty GraphicsPlaceholder
array. Custom UI components have no children. Setting this property has no
effect.
Visibility of the object handle, specified as "on",
"callback", or "off".
This property controls the visibility of the object in the list of children for
its parent. When an object is not visible in the list of children for its parent, it
is not returned by functions that obtain objects by searching the object hierarchy or
querying properties. These functions include get, findobj, clf, and close. Objects are valid even if they are
not visible. If you can access an object, you can set and get its properties, and pass
it to any function that operates on objects.
HandleVisibility Value | Description |
|---|---|
"on" | The object is always visible. |
"callback" | The object is visible from within callbacks or functions invoked by callbacks, but not from within functions invoked from the command line. This option blocks access to the object at the command line, but allows callback functions to access it. |
"off" | The object is invisible at all times. This option is useful for
preventing unintended changes to the UI by another function. Set the
HandleVisibility to "off" to
temporarily hide the object during the execution of that function. |
Identifiers
This property is read-only.
Type of UI component object, represented as the character vector
'optics.ui.opticalmaterialpicker'.
Object identifier, specified as a character
vector or string scalar. You can specify a unique Tag value to
serve as an identifier for an object. When you need access to the object elsewhere in
your code, you can use the findobj function to search for the object
based on the Tag value.
User data, specified as any MATLAB array. For example, you can specify a scalar, vector, matrix, cell array, character array, table, or structure. Use this property to store arbitrary data on an object.
If you are working in App Designer, create public or private properties in the app
to share data instead of using the UserData property. For more
information, see Share Data Within a Single App Designer App.
Clipping
Clipping of objects to the axes limits, specified as "on" or
"off", or as numeric or logical 1
(true) or 0 (false). A
value of "on" is equivalent to true, and
"off" is equivalent to false. Thus, you can
use the value of this property as a logical value. The value is stored as an on/off
logical value of type matlab.lang.OnOffSwitchState.
The clipping behavior of an object within the Axes object depends on both the Clipping property of
the Axes object and the Clipping
property of the individual object. The property value of the Axes object has these effects:
"on"— Enable each individual object within the axes to control its own clipping behavior based on theClippingproperty value for the object."off"— Disable clipping for all objects within the axes, regardless of theClippingproperty value for the individual objects. Parts of objects can appear outside of the axes limits. For example, parts can appear outside the limits if you create a plot, use thehold oncommand, freeze the axis scaling, and then add a plot that is larger than the original plot.
Examples
Create a figure window with the name "My Optical Design Tool".
f = uifigure(Name="My Optical Design Tool",WindowState="maximized");
Create a 2-by-1 grid layout within the figure.
mainLayout = uigridlayout(f,[2 1],RowHeight="fit");Add a panel to the first slot of the grid. Add optical design controls to the panel. Then, add a radio button group enabling you to select between the lens, diaphragm, mirror, and image plane optical components.
topPanel = uipanel(mainLayout); bg = uibuttongroup(topPanel,Title="Select Optical Component",Position=[10 10 100 125]); rb1 = uiradiobutton(bg,Position=[10 82 91 15],Text="Lens"); rb2 = uiradiobutton(bg,Position=[10 60 91 15],Text="Diaphragm"); rb3 = uiradiobutton(bg,Position=[10 38 91 15],Text="Mirror"); rb4 = uiradiobutton(bg,Position=[10 16 91 15],Text="Image Plane");
Add a panel in the second slot of the grid. Add an optical material picker to the panel.
bottomPanel = uipanel(mainLayout);
picker = opticalMaterialPicker(Parent=bottomPanel,Units="pixels",Position=[1 1 640 820]);
You can similarly integrate the optical material picker into any custom UI that you create for optical system design and simulation applications.
More About
To receive notification from the OpticalMaterialPicker
object when you select a new material, set up a listener for the
MaterialSelectionChanged event. You can specify a callback function that
executes when you select a new material. When the OpticalMaterialPicker
object notifies your application through the listener, it returns data specific to the
event.
| Event Name | Trigger | Event Data | Event Attributes |
|---|---|---|---|
MaterialSelectionChanged | A new optical material has been selected, either through the UI or
programmatically using the SelectedMaterial property. | optics.ui.MaterialSelectionEventData |
|
The optical material picker UI has these features.
The picker loads glass materials from both the glass library and the MATLAB workspace. If a glass material from the workspace exists in the glass library by name and catalog, the picker does not duplicate the glass material.
Filter Glass Materials
UI Interface Description 
You can filter glasses based on the refractive index, Abbe number, supported wavelengths, and glass name hint using the controls in the Filters section of the UI.
You can switch between viewing your filtered glasses and all glasses by toggling between Filters ON and Show All Glasses, respectively.
Select Glass Material
UI Interface Description 

The picker enables you to choose between the Catalog and Glass List view and Abbe Diagram view of the filtered glasses. You can pick a glass material from either view.
In the Catalog and Glass List view, the picker groups the glass materials by their
CatalogNameproperty. The picker groups glass materials in the workspace that have an emptyCatalogNameproperty under a defaultWorkspacecatalog.For glass materials in the workspace that have an empty
MaterialNameproperty, the picker assigns a default name based on military specifications.
Analyze Selected Glass Material
UI Interface Description 
The picker shows the details of the selected optical material, and the plot of its refractive index with respect to wavelengths, in the Selected Optical Material section of the UI.
The picker shows the refractive index plot for the selected wavelength range.
If you do not apply the wavelength range filter, the picker shows the refractive index plot for the supported wavelength range of the selected material.
If the selected material does not have a specified supported wavelength range, the picker shows the refractive index plot for the visible spectrum.
If the glass material you pick does not have refractive index data, the picker shows an empty refractive index plot.
Version History
Introduced in R2026a
See Also
Apps
Objects
Functions
Classes
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)