Is your feature request related to a problem? Please describe.
Some components allow selecting Geometric Model and Category instances. When that happens, we add relevant Model / SubCategory ids to HiliteSet to hilite elements in selected model or category. However, SelectionSet only allows adding geometric element ids, so we end up with the situation where users think that something is selected (because something is hilited), but the tools don't see that (because SelectionSet is empty). For example, the "Clear selection" tool doesn't even show up, because it doesn't get notified that something is selected. Even if it did, the "Clear" action on SelectionSet would be a no-op, because it's empty.
Describe the solution you'd like
Make SelectionSet store selection in a similar structure as HiliteSet. This way, when a Model / Category is selected, we can add Model / SubCategories to SelectionSet, like we do in HiliteSet.
Adding such an id would trigger the onChanged event and affect the empty, size, emptyAll methods.
The elements getter and existing SelectionSet modification methods would continue working as before.
We'd add models and subCategories getters to modify and access selected Model / SubCategory ids.
Existing tools would only be aware of elements' selection, but could be enhanced to also consider Model / Category selection.
Things to consider with this solution:
Changing ElementSetTool.setPreferredElementSource to also check if any models or sub-categories are selected when there are no geometric elements selected and outputting an informational message or something to let users know why hilited stuff is rejected.
Make tools work with models and sub-categories:
Provide a way to change Model / SubCategory selection to Element selection.
Enhance the tools to work with Models / SubCategories as first class citizen. IMO, this should be preferred over the above, because handling a "model" could be made much more efficient than handling potentially millions of models elements directly.
Describe alternatives you've considered
When a Model / Category is selected, add their elements to SelectionSet.
Reasons rejected:
This could potentially add very large sets of elements to SelectionSet, which could cause performance issues.
Loss of context.
Difficulties synchronizing SelectionSet with unified selection storage.
Enhance SelectionSet to have something like "selection mode", which would default to Element, but could also be Model or Category. The mode would tell what the selected ids mean, changing mode or adding ids with different mode would clear existing ids.
Reason rejected:
This would only support one type of ids being selected at a time, which is not flexible enough - our UI components support selecting multiple types of ids at once.
Is your feature request related to a problem? Please describe.
Some components allow selecting Geometric Model and Category instances. When that happens, we add relevant Model / SubCategory ids to
HiliteSet
to hilite elements in selected model or category. However,SelectionSet
only allows adding geometric element ids, so we end up with the situation where users think that something is selected (because something is hilited), but the tools don't see that (becauseSelectionSet
is empty). For example, the "Clear selection" tool doesn't even show up, because it doesn't get notified that something is selected. Even if it did, the "Clear" action onSelectionSet
would be a no-op, because it's empty.Describe the solution you'd like
Make
SelectionSet
store selection in a similar structure asHiliteSet
. This way, when a Model / Category is selected, we can add Model / SubCategories toSelectionSet
, like we do inHiliteSet
.onChanged
event and affect theempty
,size
,emptyAll
methods.elements
getter and existingSelectionSet
modification methods would continue working as before.models
andsubCategories
getters to modify and access selected Model / SubCategory ids.Things to consider with this solution:
ElementSetTool.setPreferredElementSource
to also check if any models or sub-categories are selected when there are no geometric elements selected and outputting an informational message or something to let users know why hilited stuff is rejected.Describe alternatives you've considered
When a Model / Category is selected, add their elements to
SelectionSet
.Reasons rejected:
SelectionSet
, which could cause performance issues.SelectionSet
with unified selection storage.Enhance
SelectionSet
to have something like "selection mode", which would default to Element, but could also be Model or Category. The mode would tell what the selected ids mean, changing mode or adding ids with different mode would clear existing ids.Reason rejected:
Additional context
Based on https://github.com/iTwin/viewer-components-react/issues/1099.