6.11. gui Submodule¶
6.11.1. gui.command_window¶
- class optrace.gui.command_window.CommandWindow(gui)¶
Initialize the command window
- Parameters:
gui (TraceGUI) – parent TraceGUI
- clear_history(event=None)¶
clear command history :param event: optional trait change event
- Parameters:
event (TraitChangeEvent)
- Return type:
None
- copy_history(event=None)¶
copy the full history to the clipboard :param event: optional trait change event
- Parameters:
event (TraitChangeEvent)
- Return type:
None
- send_command(event=None)¶
Execute the entered command in the TraceGUI
- Parameters:
event (TraitChangeEvent) – optional trait change event
- Return type:
None
6.11.2. gui.property_browser¶
- class optrace.gui.property_browser.PropertyBrowser(gui)¶
Initialize a PropertyBrowser
- Parameters:
gui (TraceGUI) – reference to the TraceGUI
- update_dict(event=None)¶
Update the dictionaries in all ValueEditor()
- Parameters:
event (TraitChangeEvent) – optional trait change event
- Return type:
None
6.11.3. gui.trace_gui¶
- class optrace.gui.trace_gui.TraceGUI(raytracer, initial_camera={}, **kwargs)¶
Create a new TraceGUI with the assigned Raytracer.
- Parameters:
- add_custom_button(name, function)¶
Add a custom button with an action to the “custom” GUI tab.
- add_custom_checkbox(name, val, function=None)¶
Add a custom checkbox with an action to the “custom” GUI tab.
- add_custom_selection(name, list_, val, function=None)¶
Add a custom selection field with an action to the “custom” GUI tab.
- add_custom_value(name, val, function=None)¶
Add a custom float value field with an action to the “custom” GUI tab.
- close(event=None)¶
Close the whole application.
- Parameters:
event (TraitChangeEvent) – optional trait change event
- Return type:
None
- control(func, args=(), kwargs={})¶
Interact with the TraceGUI. Function ‘func’ is executed in the main thread after the TraceGUI is loaded.
- debug(func, args=(), kwargs={})¶
Control the GUI from a separate thread.
- detector_image(event=None, profile=False, extent=None, **kwargs)¶
Render a detector image at the chosen Detector, uses a separate thread.
- detector_profile(event=None, extent=None, **kwargs)¶
Plot a detector image profile.
- detector_spectrum(event=None, extent=None, **kwargs)¶
Render a Detector Spectrum for the chosen Source, uses a separate thread.
- Parameters:
event (TraitChangeEvent) – optional trait change event
extent (list | ndarray) – image extent, see Raytracer.detector_image()
kwargs – additional keyword arguments for spectrum_plot
- Return type:
None
- get_camera()¶
Get the camera parameters that can be passed down to set_camera()
- move_to_focus(event=None, **kwargs)¶
Find a Focus. The chosen Detector defines the search range for focus finding. Searches are always between lenses or the next outline. Search takes place in a separate thread, after that the Detector is moved to the focus
- Parameters:
event (TraitChangeEvent) – optional trait change event
kwargs – additional keyword arguments for focus_search_cost_plot
- Return type:
None
- open_command_window(event=None)¶
Open the command window for executing code.
- Parameters:
event (TraitChangeEvent) – optional trait change event
- Return type:
None
- open_documentation(event=None)¶
Open the online documentation https://drocheam.github.io/optrace in a browser
- Parameters:
event (TraitChangeEvent) – optional trait change event
- Return type:
None
- open_property_browser(event=None)¶
Open a property browser for the gui, the scene, the raytracer, shown rays and cardinal points.
- Parameters:
event (TraitChangeEvent) – optional trait change event
- Return type:
None
- pick_ray(index)¶
Pick a ray with index ‘index’. The selected ray is highlighted.
- Parameters:
index (int) – is the index of the displayed rays.
- Return type:
None
- pick_ray_section(index, section, detailed=False)¶
Pick a ray with index ‘index’ at intersection number ‘section’. A ray highlight plot, crosshair and ray info text are shown.
- process()¶
Force an update to traits and unprocessed events.
- Return type:
None
- replot(change=None)¶
replot all or part of the geometry and scene. If the change dictionary is not provided, everything is replotted according to the raytracer geometry
- Parameters:
change (dict) – optional change dict from raytracer.compare_property_snapshot
- Return type:
None
- replot_rays(event=None, mask=None, max_show=None)¶
choose a subset of all raytracer rays and plot them with :TraceGUI._plot_rays.
By default, a random subset is selected. When mask and max_show (both optional) are provided, a specific subset is displayed. See TraceGUI.select_rays.
- Parameters:
event (TraitChangeEvent) – optional trait change event
mask (ndarray) – boolean array for which rays to display. Shape must equal the number of currently traced rays.
max_show (int) – maximum number of rays to display
- Return type:
None
- reset_picking()¶
Hide/reset the displayed picker objects. Hides the ray info text, ray highlight and crosshair that have been created with TraceGUI.pick_ray or TraceGUI.pick_ray_section
- Return type:
None
- retrace(event=None)¶
raytrace in separate thread, after that call TraceGUI.replot_rays.
- Parameters:
event (TraitChangeEvent) – optional trait change event
- Return type:
None
- run()¶
Run the TraceGUI
- Return type:
None
- screenshot(path, **kwargs)¶
Save a screenshot of the scene. Passes the parameters down to the mlab.savefig function. See https://docs.enthought.com/mayavi/mayavi/auto/mlab_figure.html#savefig for parameters.
- Parameters:
path (str)
- Return type:
None
- select_rays(mask, max_show=None)¶
Apply a specific selection of rays for display. If the number is too large it is either limited by the ‘max_show’ parameter or a predefined limit.
- set_camera(center=None, height=None, direction=None, roll=None)¶
Sets the camera view. Not all parameters must be defined, setting single properties is also allowed.
- Parameters:
focal_point – 3D position of camera focal point, also defines the center of the view
parallel_scale – view scaling. Defines half the size of the view in vertical direction.
center (ndarray) – 3D coordinates of center of view
height (float) – half of vertical height in mm
direction (list) – camera view direction vector (direction of vector perpendicular to your monitor and in your viewing direction)
roll (float) – absolute camera roll angle
- Return type:
None
- smart_replot(automatic_replot=True)¶
This contextmanager makes a property snapshot of the raytracer before and after a specific action. If changes are detected. the corresponding elements are updated.
- Parameters:
automatic_replot (bool) – if automatic replotting should be executed
- Return type:
None
- source_image(event=None, profile=False, **kwargs)¶
Render a source image for the chosen Source, uses a separate thread
- Parameters:
event – optional trait change event
profile (bool) – if an Image profile plot is plotted
kwargs – additional keyword arguments for image_plot
- Return type:
None
- source_profile(event=None, **kwargs)¶
Plot a source image profile.
- Parameters:
event – optional trait change event
kwargs – additional keyword arguments for image_profile_plot
- Return type:
None
- source_spectrum(event=None, **kwargs)¶
render a Source Spectrum for the chosen Source, uses a separate thread.
- Parameters:
event (TraitChangeEvent) – optional trait change event
kwargs – additional keyword arguments for spectrum_plot
- Return type:
None
- coloring_modes: list = ['Plain', 'Power', 'Wavelength', 'Source', 'Polarization xz', 'Polarization yz', 'Refractive Index']¶
available ray coloring modes
- flip_detector_image: List¶
Boolean value for flipping the image (rotating it by 180°). Packed as Checkbox into a
List
- image_pixels: Enum¶
Image Pixel value for Source/Detector Image. This the number of pixels for the smaller image side.
- log_image: List¶
Boolean value for a logarithmic image visualization. Packed as Checkbox into a
List
- projection_method_enabled: Bool = False¶
if method is selectable, only the case for spherical detectors
- property ray_selection: ndarray¶
- Returns:
boolean array for which of the traced rays in TraceGUI.raytracer.rays are displayed currently
- vertical_labels: List¶
in geometries with tight geometry and long descriptions one could want to display the labels vertically
- view¶
the UI view