Customizing Context Menus

Introduction

Many widgets in the main application window have customizable context menus. Each customizable context menu uses ContextMenuAction objects that define a unique ID for the action and optional placement using an additional "buddy" action. The menu actions are customized in a ContextMenu.

Since each context menu may have different actions, debugging support is provided through the message log. Call the ContextMenu::setSettingLogActions() method to enable or disable logging of the actions.

Warning:
Context menu logging is provided for debugging purposes only and is therefore only available in debug mode. Enabling the logging will do nothing in a release mode version of the application.

Calling Sequence

When the user right-clicks on a widget containing a customizable context menu, the following calling sequence is invoked:
  1. The SessionItem::getContextMenuActions() method is called to get the default list of ContextMenuActions for that session item. This may include actions for additional session items, if the context areas of multiple session items are to be combined.
  2. The ContextMenu is created.
  3. If ContextMenu::hasSettingLogActions() and ContextMenu::getSettingLogActions() both return true, the default actions are recorded in the message log.
  4. The DesktopServices::signalAboutToShowContextMenu() signal is emitted with the ContextMenu value indicating that the menu is about to be displayed. This gives attached objects a chance to add actions to the default list or to remove actions from the list. Custom actions can also be created based on the current state of the session item(s) or the point on which the user clicked to invoke the menu.
  5. A custom widget signal may be emitted indicating that the user clicked in that particular widget. This provides the capability for objects to attach to a particular session item signal instead of the DesktopServices::signalAboutToShowContextMenu() signal. Available session item signals include the following:
  6. If the user clicked on a session item in the session explorer, the SessionExplorer::signalAboutToShowSessionItemContextMenu() signal is emitted. The context menu will contain the session item(s) that are currently selected in the session explorer. If only one session item is selected, the menu contains the actions returned by SessionItem::getContextMenuActions() for that item. If multiple session items are selected in the session explorer, the menu initially contains no actions. Objects that are attached to the DesktopServices::signalAboutToShowContextMenu() signal may also need to attach to the SessionExplorer::signalAboutToShowSessionItemContextMenu() signal if they are interested in the selected item(s) in the session explorer.
  7. After all slot methods connected to each signal are called, if ContextMenu::hasSettingLogActions() and ContextMenu::getSettingLogActions() both return true, the actions that will be used in the menu is recorded in the message log. These actions are the raw ContextMenuAction object and not the final QAction list that is displayed in the menu so that the placement and removal of the actions is displayed.
  8. A list of QActions that will be displayed in the menu is generated from all ContextMenuAction objects. First, all actions are ordered according to the buddy action in each ContextMenuAction. After all actions have been ordered, actions are removed.
  9. The context menu is displayed to the user with the generated list of QActions.

Default Context Menu Actions

Each action that may be added to a default context menu is listed in the sections below according to the class that defines the action. Each action ID is provided for objects to remove them as necessary. The ID values in the tables do not represent the string value to pass into the ContextMenu methods to add and remove actions, but rather a corresponding #define that can be used in place of the ID string. All action #defines are located in the ContextMenuActions.h file.

Each of the ID names is prefixed with APP_ to prevent collisions with other action IDs defined in plug-ins. When creating context menu actions in a plug-in, be sure to use a similar approach of prefixing the ID string with a namespace identifier to avoid ID collisions with other plug-ins.

Animation Controller

ActionID
PauseAPP_ANIMATIONCONTROLLER_PAUSE_ACTION()
PlayAPP_ANIMATIONCONTROLLER_PLAY_ACTION()
Change directionAPP_ANIMATIONCONTROLLER_CHANGE_DIRECTION_ACTION()
Step backwardAPP_ANIMATIONCONTROLLER_STEP_BACKWARD_ACTION()
Step forwardAPP_ANIMATIONCONTROLLER_STEP_FORWARD_ACTION()
StopAPP_ANIMATIONCONTROLLER_STOP_ACTION()
SeparatorAPP_ANIMATIONCONTROLLER_BUMPER_SEPARATOR_ACTION()
Bumpers EnabledAPP_ANIMATIONCONTROLLER_ENABLE_BUMPERS_ACTION()
Left Bumper to Current FrameAPP_ANIMATIONCONTROLLER_SET_LEFT_BUMPER_ACTION()
Right Bumper to Current FrameAPP_ANIMATIONCONTROLLER_SET_RIGHT_BUMPER_ACTION()
Adjust Bumpers...APP_ANIMATIONCONTROLLER_ADJUST_BUMPERS_ACTION()
Reset BumpersAPP_ANIMATIONCONTROLLER_RESET_BUMPERS_ACTION()
SeparatorAPP_ANIMATIONCONTROLLER_STORE_BUMPERS_SEPARATOR_ACTION()
Store BumpersAPP_ANIMATIONCONTROLLER_STORE_BUMPERS_ACTION()
Restore BumpersAPP_ANIMATIONCONTROLLER_RESTORE_BUMPERS_ACTION()
SeparatorAPP_ANIMATIONCONTROLLER_DROP_FRAMES_SEPARATOR_ACTION()
Can Drop FramesAPP_ANIMATIONCONTROLLER_DROP_FRAMES_ACTION()

Animation Services

ActionID
ActivateAPP_ANIMATIONSERVICES_ACTIVATE_ACTION()
DeleteAPP_ANIMATIONSERVICES_DELETE_ACTION()
SeparatorAPP_ANIMATIONSERVICES_SEPARATOR_ACTION()

Application Window

ActionID
Copy snapshotAPP_APPLICATIONWINDOW_COPY_SNAPSHOT_ACTION()
SeparatorAPP_APPLICATIONWINDOW_COPY_SNAPSHOT_SEPARATOR_ACTION()
Copy snapshotAPP_APPLICATIONWINDOW_COPY_SNAPSHOT_SIZED_ACTION()
Delete Data ElementAPP_APPLICATIONWINDOW_DATAELEMENT_DELETE_ACTION()
Edit ClassificationAPP_APPLICATIONWINDOW_EDIT_CLASSIFICATION_ACTION()
ExportAPP_APPLICATIONWINDOW_EXPORT_ACTION()
LinkAPP_APPLICATIONWINDOW_LINK_ACTION()
SeparatorAPP_APPLICATIONWINDOW_LINK_SEPARATOR_ACTION()
PropertiesAPP_APPLICATIONWINDOW_PROPERTIES_ACTION()
UnlinkAPP_APPLICATIONWINDOW_UNLINK_ACTION()

Cartesian Plot

In addition to the actions listed below, the context menu for a CartesianPlot also includes all PlotView actions.

ActionID
Custom zoomAPP_CARTESIANPLOT_CUSTOM_ZOOM_ACTION()
Gridlines menuAPP_CARTESIANPLOT_GRIDLINES_MENU_ACTION()

Dock Window

ActionID
DockAPP_DOCKWINDOW_DOCK_ACTION()
HideAPP_DOCKWINDOW_HIDE_ACTION()
ShowAPP_DOCKWINDOW_SHOW_ACTION()
UndockAPP_DOCKWINDOW_UNDOCK_ACTION()

Graphic Layer

ActionID
DeleteAPP_GRAPHICLAYER_OBJECT_DELETE_ACTION()
SeparatorAPP_GRAPHICLAYER_OBJECT_DELETE_SEPARATOR_ACTION()

Histogram Plot

In addition to the actions listed below, the context menu for a HistogramPlot also includes all CartesianPlot actions.

ActionID
Auto ZoomAPP_HISTOGRAMPLOT_AUTO_ZOOM_ACTION()
Axis Scale menuAPP_HISTOGRAMPLOT_AXIS_SCALE_MENU_ACTION()
Bad ValuesAPP_HISTOGRAMPLOT_BAD_VALUES_ACTION()
Displayed Band menuAPP_HISTOGRAMPLOT_BAND_MENU_ACTION()
Color Map menuAPP_HISTOGRAMPLOT_COLOR_MAP_MENU_ACTION()
Complex Data menuAPP_HISTOGRAMPLOT_COMPLEX_DATA_MENU_ACTION()
Displayed Element menuAPP_HISTOGRAMPLOT_ELEMENT_MENU_ACTION()
SeparatorAPP_HISTOGRAMPLOT_END_SEPARATOR_ACTION()
Pass Area menuAPP_HISTOGRAMPLOT_PASS_AREA_MENU_ACTION()
SeparatorAPP_HISTOGRAMPLOT_RASTER_MENUS_SEPARATOR_ACTION()
SeparatorAPP_HISTOGRAMPLOT_RASTER_SEPARATOR_ACTION()
Refresh StatisticsAPP_HISTOGRAMPLOT_REFRESH_STATISTICS_ACTION()
Set Spatial SamplingAPP_HISTOGRAMPLOT_SAMPLING_ACTION()
SaveAPP_HISTOGRAMPLOT_SAVE_ACTION()
StatisticsAPP_HISTOGRAMPLOT_STATISTICS_ACTION()
Stretch Favorites menuAPP_HISTOGRAMPLOT_STRETCH_FAVORITES_MENU_ACTION()
Stretch Reset menuAPP_HISTOGRAMPLOT_STRETCH_RESET_MENU_ACTION()
Stretch Type menuAPP_HISTOGRAMPLOT_STRETCH_TYPE_MENU_ACTION()
Synchronize Auto ZoomAPP_HISTOGRAMPLOT_SYNCHRONIZE_AUTO_ZOOM_ACTION()
SeparatorAPP_HISTOGRAMPLOT_THRESHOLD_SEPARATOR_ACTION()
Stretch/Threshold Units menuAPP_HISTOGRAMPLOT_UNITS_MENU_ACTION()

Layer

ActionID
DisplayedAPP_LAYER_DISPLAYED_ACTION()

Plot Set

ActionID
Activate PlotAPP_PLOTSET_ACTIVATE_ACTION()
DeleteAPP_PLOTSET_DELETE_ACTION()
SeparatorAPP_PLOTSET_SEPARATOR_ACTION()

Plot View

ActionID
Mouse mode menuAPP_PLOTVIEW_MOUSE_MODE_MENU_ACTION()
SeparatorAPP_PLOTVIEW_MOUSE_MODE_SEPARATOR_ACTION()
Rescale axesAPP_PLOTVIEW_RESCALE_AXES_ACTION()
SeparatorAPP_PLOTVIEW_RESCALE_AXES_SEPARATOR_ACTION()

Plot Widget

In addition to the actions listed below, the context menu for a PlotWidget widget also includes all plot view actions for the specific plot view displayed in the plot widget. See the specific plot view documentation for the list of the plot view's actions.

ActionID
LegendAPP_PLOTWIDGET_LEGEND_ACTION()
SeparatorAPP_PLOTWIDGET_LEGEND_SEPARATOR_ACTION()
PrintAPP_PLOTWIDGET_PRINT_ACTION()
SeparatorAPP_PLOTWIDGET_PRINT_SEPARATOR_ACTION()
Toolbars menuAPP_PLOTWIDGET_TOOLBARS_MENU_ACTION()

Polar Plot

In addition to the actions listed below, the context menu for a PolarPlot also includes all PlotView actions.

ActionID
Gridlines menuAPP_POLARPLOT_GRIDLINES_MENU_ACTION()

Product View

ActionID
ActivateAPP_PRODUCTVIEW_LAYER_ACTIVATE_ACTION()
ActivateAPP_PRODUCTVIEW_PROPERTIES_SEPARATOR_ACTION()

Raster Layer

In addition to the actions listed below, the context menu for a RasterLayer also includes all Layer actions.

ActionID
Calculate Statistics on SubsetAPP_LAYER_CALCULATE_SUBSET_STATISTICS_ACTION()
Display as menuAPP_RASTERLAYER_DISPLAY_AS_MENU_ACTION()
Display mode menuAPP_RASTERLAYER_DISPLAY_MODE_MENU_ACTION()
SeparatorAPP_RASTERLAYER_SEPARATOR_ACTION()
Image stretch menuAPP_RASTERLAYER_STRETCH_MENU_ACTION()

Session Explorer

In addition to the actions listed below, the context menu for the session explorer also includes all DockWindow actions.

ActionID
Collapse AllAPP_SESSIONEXPLORER_COLLAPSE_ALL_ACTION()
Copy name to clipboardAPP_SESSIONEXPLORER_COPY_NAME_TO_CLIPBOARD_ACTION()
Expand AllAPP_SESSIONEXPLORER_EXPAND_ALL_ACTION()
RenameAPP_SESSIONEXPLORER_RENAME_ACTION()
SeparatorAPP_SESSIONEXPLORER_SEPARATOR_ACTION()

Spatial Data View

ActionID
AxisAPP_SPATIALDATAVIEW_AXIS_ACTION()
Background ColorAPP_SPATIALDATAVIEW_BACKGROUND_COLOR_ACTION()
CrosshairAPP_SPATIALDATAVIEW_CROSSHAIR_ACTION()
SeparatorAPP_SPATIALDATAVIEW_CROSSHAIR_SEPARATOR_ACTION()
Hide LayersAPP_SPATIALDATAVIEW_HIDE_LAYERS_ACTION()
Select Layers of TypeAPP_SPATIALDATAVIEW_SELECT_LAYERS_OF_TYPE_ACTION()
ActivateAPP_SPATIALDATAVIEW_LAYER_ACTIVATE_ACTION()
SeparatorAPP_SPATIALDATAVIEW_LAYER_ACTIVATE_SEPARATOR_ACTION()
ConvertAPP_SPATIALDATAVIEW_LAYER_CONVERT_ACTION()
CopyAPP_SPATIALDATAVIEW_LAYER_COPY_ACTION()
DeleteAPP_SPATIALDATAVIEW_LAYER_DELETE_ACTION()
SeparatorAPP_SPATIALDATAVIEW_LAYER_DELETE_SEPARATOR_ACTION()
Layer menuAPP_SPATIALDATAVIEW_LAYER_MENU_ACTION()
SeparatorAPP_SPATIALDATAVIEW_LAYER_SEPARATOR_ACTION()
Measurements PropertiesAPP_SPATIALDATAVIEW_MEASUREMENTS_PROPERTIES_ACTION()
New Layer menuAPP_SPATIALDATAVIEW_NEW_LAYER_MENU_ACTION()
OriginAPP_SPATIALDATAVIEW_ORIGIN_ACTION()
Origin Location menuAPP_SPATIALDATAVIEW_ORIGIN_MENU_ACTION()
SeparatorAPP_SPATIALDATAVIEW_ORIGIN_SEPARATOR_ACTION()
SeparatorAPP_SPATIALDATAVIEW_PROPERTIES_SEPARATOR_ACTION()
Show LayersAPP_SPATIALDATAVIEW_SHOW_LAYERS_ACTION()
SmoothAPP_SPATIALDATAVIEW_SMOOTH_ACTION()

Threshold Layer

In addition to the actions listed below, the context menu for a ThresholdLayer also includes all Layer actions.

ActionID
Calculate Statistics on SubsetAPP_LAYER_CALCULATE_SUBSET_STATISTICS_ACTION()

Toolbar

ActionID
HideAPP_TOOLBAR_HIDE_ACTION()
ShowAPP_TOOLBAR_SHOW_ACTION()

Workspace Window

ActionID
ActivateAPP_WORKSPACEWINDOW_ACTIVATE_ACTION()

Software Development Kit - Opticks 4.9.0 Build 16218