Commit 8c1a38b8 authored by Frédéric Larue's avatar Frédéric Larue

Mechanism for the processing of selected entities enabled.

parent a5a6f315
......@@ -1322,73 +1322,69 @@ void GLViewer::updateSelectionZBuffer()
void GLViewer::processSelection( BaseSelectionProcessor &proc )
{
std::list<BaseSelectionProcessor*> procList;
procList.push_back( &proc );
QList<BaseSelectionProcessor*> procList;
procList << &proc;
processSelection( procList );
}
void GLViewer::processSelection( std::list<BaseSelectionProcessor*> &procList )
void GLViewer::processSelection( QList<BaseSelectionProcessor*> &procList )
{
#if 0
std::map< TypeId, BaseSelectionProcessor* > processorByType;
QMap< QString, BaseSelectionProcessor* > processorByType;
for( std::list<BaseSelectionProcessor*>::iterator p=procList.begin(); p!=procList.end(); ++p )
for( BaseSelectionProcessor* p : procList )
{
std::list<TypeId> acceptedTypes;
(*p)->acceptedDataType( acceptedTypes );
QStringList acceptedTypes;
p->acceptedDataType( acceptedTypes );
for( std::list<TypeId>::iterator t=acceptedTypes.begin(); t!=acceptedTypes.end(); ++t )
processorByType[*t] = *p;
for( QString& type : acceptedTypes )
processorByType[type] = p;
}
for( DisplayableMap::iterator d=m_Displayables.begin(); d!=m_Displayables.end(); ++d )
for( auto& d : m_Displayables )
{
std::map< TypeId, BaseSelectionProcessor* >::iterator processorFound = processorByType.find( d->first->GetType() );
if( processorFound != processorByType.end() && (d->second.displayable->selectableEntities() & processorFound->second->entityToProcess()) )
{
d->second.displayable->processSelection( *processorFound->second );
if( processorFound->second->isSelectionResetRequired() )
d->second.displayable->clearSelection( processorFound->second->entityToProcess() );
if( processorFound->second->isDisplayableUpdateRequired() )
updateDisplayable( d->second.displayable->getSrcManageable() );
}
QMap< QString, BaseSelectionProcessor* >::iterator processorFound = processorByType.find( d.first->GetTypeString() );
if( processorFound != processorByType.end() )
processSelection( d.second, *processorFound.value() );
}
#endif
}
void GLViewer::processSelection( GenericUIData *m, BaseSelectionProcessor &proc )
{
#if 0
DisplayableMap::iterator displayableFound = m_Displayables.find( m );
if( displayableFound != m_Displayables.end() )
processSelection( displayableFound->second, proc );
}
if( displayableFound == m_Displayables.end() )
return;
DisplayableInterface *d = displayableFound->second.displayable;
void GLViewer::processSelection( DisplayableInfo &dInfo, BaseSelectionProcessor &proc )
{
DisplayableInterface *d = dInfo.displayable;
GenericUIData *m = d->getSource();
SelectionManager *mgr = dInfo.selectionMgr;
if( mgr->selectableEntity() != proc.entityToProcess() )
return;
std::list<TypeId> acceptedTypes;
QStringList acceptedTypes;
proc.acceptedDataType( acceptedTypes );
for( std::list<TypeId>::iterator t=acceptedTypes.begin(); t!=acceptedTypes.end(); ++t )
if( m->GetType() == *t )
{
if( d->selectableEntities() & proc.entityToProcess() )
{
d->processSelection( proc );
if( proc.isSelectionResetRequired() )
d->clearSelection( proc.entityToProcess() );
if( proc.isDisplayableUpdateRequired() )
updateDisplayable( m );
}
if( acceptedTypes.contains(m->GetTypeString()) )
{
proc.init( m );
d->processSelection( mgr, proc );
proc.release( m );
break;
if( proc.isSelectionResetRequired() )
mgr->clearSelection();
if( proc.isDisplayableUpdateRequired() )
{
updateDisplayable( m );
updateSelectionZBuffer();
}
#endif
}
}
......
......@@ -217,6 +217,8 @@ protected:
QMatrix4x4 reframedProjection( float viewportX, float viewportY, float viewportW, float viewportH );
void processSelection( DisplayableInfo &dInfo, BaseSelectionProcessor &proc );
public:
void init( DisplayDoF dof );
......@@ -309,7 +311,7 @@ public:
inline bool isSelectionEnabled() const { return m_SelectionEnabled; }
inline const SelectionTool& currentSelectionTool() const { return *m_SelectionCurrentTool; }
void processSelection( BaseSelectionProcessor &proc );
void processSelection( std::list<BaseSelectionProcessor*> &procList );
void processSelection( QList<BaseSelectionProcessor*> &procList );
void processSelection( GenericUIData *m, BaseSelectionProcessor &proc );
void renderCoords( double x, double y, double z, double *screenX, double *screenY );
......
......@@ -11,8 +11,9 @@
#include "../GPU/GPU.h"
class GLViewer;
#include <QtGui>
class GLViewer;
class GenericUIData;
......@@ -102,7 +103,12 @@ public:
inline bool isDisplayableUpdateRequired() const { return m_UpdateDisplay; }
inline bool isSelectionResetRequired() const { return m_ResetSelection; }
virtual void acceptedDataType( QStringList &types ) const = 0;
virtual SelectableEntity entityToProcess() const = 0;
virtual void init( GenericUIData *m ) {}
virtual void operator()( void* data ) = 0;
virtual void release( GenericUIData *m ) {}
};
......
......@@ -139,6 +139,8 @@ public:
inline bool isAnimationPaused() const { return m_IsAnimationPaused; }
virtual void processSelection( SelectionManager *mngr, BaseSelectionProcessor &proc ) {}
signals:
void registerAnimation( DisplayableInterface *d );
void unregisterAnimation( DisplayableInterface *d );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment