IECore::PathMatcher SceneGadget::convertSelection( IECore::UIntVectorDataPtr ids ) const { CompoundDataMap parameters = { { "selection", ids } }; if( m_selectionMask ) { parameters["mask"] = m_selectionMask; } auto pathsData = static_pointer_cast<PathMatcherData>( m_renderer->command( "gl:querySelection", parameters ) ); PathMatcher result = pathsData->readable(); // Unexpanded locations are represented with // objects named __unexpandedChildren__ to allow // locations to have an object _and_ children. // We want to replace any such locations with their // parent location. const InternedString unexpandedChildren = "__unexpandedChildren__"; vector<InternedString> parent; PathMatcher toAdd; PathMatcher toRemove; for( PathMatcher::Iterator it = result.begin(), eIt = result.end(); it != eIt; ++it ) { if( it->size() && it->back() == unexpandedChildren ) { toRemove.addPath( *it ); parent.assign( it->begin(), it->end() - 1 ); toAdd.addPath( parent ); } } result.addPaths( toAdd ); result.removePaths( toRemove ); return result; }