+
+void LightApp_SelectionMgr::clearSelectionCache()
+{
+ myCacheTimes.clear();
+ myCacheSelection.clear();
+}
+
+bool LightApp_SelectionMgr::isSelectionCacheEnabled() const
+{
+ return myCacheState;
+}
+
+void LightApp_SelectionMgr::setSelectionCacheEnabled( bool on )
+{
+ if ( myCacheState == on )
+ return;
+
+ myCacheState = on;
+
+ if ( !myCacheState )
+ clearSelectionCache();
+}
+
+#ifndef DISABLE_SALOMEOBJECT
+
+QList<Handle_SALOME_InteractiveObject> LightApp_SelectionMgr::selectionCache( const QString& type ) const
+{
+ QList<Handle_SALOME_InteractiveObject> res;
+
+ QStringList types;
+ if ( !type.isEmpty() )
+ types.append( type );
+ else
+ types = selectorTypes();
+
+ QSet<QString> set;
+ for ( QStringList::iterator it = types.begin(); it != types.end(); ++it ) {
+ if ( myCacheSelection.contains( *it ) ) {
+ const SelList& lst = myCacheSelection[*it];
+ for ( SelList::const_iterator itr = lst.begin(); itr != lst.end(); ++itr ) {
+ if ( !(*itr).IsNull() && !set.contains( (*itr)->getEntry() ) ) {
+ res.append( *itr );
+ set.insert( (*itr)->getEntry() );
+ }
+ }
+ }
+ }
+ return res;
+}
+
+#else
+
+QStringList LightApp_SelectionMgr::selectionCache( const QString& type ) const
+{
+ QStringList res;
+
+ QStringList types;
+ if ( !type.isEmpty() )
+ types.append( type );
+ else
+ types = selectorTypes();
+
+ QSet<QString> set;
+ for ( QStringList::iterator it = types.begin(); it != types.end(); ++it ) {
+ if ( myCacheSelection.contains( *it ) ) {
+ const SelList& lst = myCacheSelection[*it];
+ for ( SelList::const_iterator itr = lst.begin(); itr != lst.end(); ++itr ) {
+ if ( !set.contains( *itr ) ) {
+ res.append( *itr );
+ set.insert( *itr );
+ }
+ }
+ }
+ }
+ return res;
+}
+
+#endif
+
+bool LightApp_SelectionMgr::isActualSelectionCache( const QString& type ) const
+{
+ bool ok = true;
+
+ QStringList types;
+ if ( !type.isEmpty() )
+ types.append( type );
+ else
+ types = selectorTypes();
+
+ for ( QStringList::iterator it = types.begin(); it != types.end() && ok; ++it )
+ ok = myCacheTimes.contains( *it ) && myCacheTimes[*it].isValid() && myCacheTimes[*it] >= myTimeStamp;
+
+ return ok;
+}
+
+QStringList LightApp_SelectionMgr::selectorTypes() const
+{
+ QStringList types;
+ QList<SUIT_Selector*> selectorList;
+ selectors( selectorList );
+ for ( QList<SUIT_Selector*>::const_iterator it = selectorList.begin(); it != selectorList.end(); ++it ) {
+ if ( (*it)->isEnabled() )
+ types.append( (*it)->type() );
+ }
+ return types;
+}