Page MenuHomePhabricator

Give the option to easily extend the context menu for specific cirumstances
Closed, DuplicatePublic

Description

Currently it is not easily done to extend the context menu on an application/plugin basis.

Idealy it should be possible for MITK based external projects to add additional capabilities to the datamanager from the "outside" such as e.g. Rightclicking on a segmentation and adding the option to "turn into 4D" or something similar.

This bug is also intended to collect a number of use cases to have in mind when designing such a system.

Event Timeline

As I know, it is already possible to extend the context menu externally, the data manager plugin provides an extension point for this. Or does it have some limitations and could be made more generic in some way?

I should probably have been more specific and clear.

Yes currently extension points offer the capability to extend the context menu from other plugins. But as far as I am aware the extended context will be there for any noe, not just the ones one wants to provide the capability for (e.g. no "show this option just for segmentations") and I believe it also does not offer the option to provide a function only if a given number of nodes/specific types of nodes is selected (e.g. show the hierarchy change only if one segmentation and one image is selected).

Sascha, please correct me if this is already possible.

Actually it is possible to restrict context menu entries to specific data types, e.g., the segmentation plugin provides a few context menu entries for segmentations.

Have a look at mitkIContextMenuAction.h of the data manager plugin. This interface even provides you with all selected nodes. However, it is a quite nasty interface since it contains the setters of all context menu entries (which you have to implement for all derived classes, no matter if you need them).

I think it is necessary to enhance this interface in a way that it no longer depends on the concrete interface implementations (replace setters by a generic mechanism like a property list).

This is covered with the command framework in T1849.