Commit 4bfdf610 authored by Frédéric Larue's avatar Frédéric Larue

GLViewer::updateDisplayable() function modified so as to give the possibility...

GLViewer::updateDisplayable() function modified so as to give the possibility to choose which data must be effectively updated (the whole displayable, selection managers, bounding box or transform).
parent fcd87803
...@@ -450,50 +450,57 @@ DisplayableInterface* GLViewer::addDisplayable( GenericUIData *m ) ...@@ -450,50 +450,57 @@ DisplayableInterface* GLViewer::addDisplayable( GenericUIData *m )
//} //}
void GLViewer::updateDisplayable( GenericUIData *m, bool resetSelectionManagers ) void GLViewer::updateDisplayable( GenericUIData *m, DisplayableUpdateRule updatesRequired )
{ {
DisplayableMap::iterator d = m_Displayables.find( m ); DisplayableMap::iterator d = m_Displayables.find( m );
if( d != m_Displayables.end() ) if( d == m_Displayables.end() )
{ return;
// Recovers the info and the factory related to the given manageable.
DisplayableFactoryInterface *factory = m_Factories[ m->GetTypeString() ];
DisplayableInfo *dinfo = &d->second;
// Re-initializes the displayable. // Recovers the info and the factory related to the given manageable.
DisplayableFactoryInterface *factory = m_Factories[ m->GetTypeString() ];
DisplayableInfo *dinfo = &d->second;
// Re-initializes the displayable.
if( updatesRequired & UpdateDisplay )
{
dinfo->displayable->release( *m->GetDisplayOptions() ); dinfo->displayable->release( *m->GetDisplayOptions() );
dinfo->displayable->initialize( *m->GetDisplayOptions() ); dinfo->displayable->initialize( *m->GetDisplayOptions() );
}
// Update the displayable bounding box. // Update the displayable bounding box.
if( updatesRequired & UpdateBoundingBox )
dinfo->displayable->boundingBox( dinfo->boundingBox ); dinfo->displayable->boundingBox( dinfo->boundingBox );
// Update the displayable transform. // Update the displayable transform.
if( updatesRequired & UpdateTransform )
{
QMatrix4x4 tr; QMatrix4x4 tr;
dinfo->displayable->transformation( tr ); dinfo->displayable->transformation( tr );
dinfo->SetUserTransform( tr ); dinfo->SetUserTransform( tr );
}
// Re-generate the selection managers. // Re-generate the selection managers.
if( resetSelectionManagers ) if( updatesRequired & UpdateSelectionManagers )
{
dinfo->currentSelectionMgr = NULL;
for( auto mngr : dinfo->selectionMgr )
delete mngr;
dinfo->selectionMgr.clear();
dinfo->displayable->selectionManagers( dinfo->selectionMgr );
if( isSelectionEnabled() )
{ {
dinfo->currentSelectionMgr = NULL;
for( auto mngr : dinfo->selectionMgr ) for( auto mngr : dinfo->selectionMgr )
delete mngr; if( mngr->selectableEntity() == m_SelectionCurrentTool->entityToSelect() )
dinfo->selectionMgr.clear(); {
dinfo->displayable->selectionManagers( dinfo->selectionMgr ); dinfo->currentSelectionMgr = mngr;
mngr->onRecompilingSelectionShader( m_SelectionCurrentTool );
if( isSelectionEnabled() ) break;
{ }
for( auto mngr : dinfo->selectionMgr )
if( mngr->selectableEntity() == m_SelectionCurrentTool->entityToSelect() )
{
dinfo->currentSelectionMgr = mngr;
mngr->onRecompilingSelectionShader( m_SelectionCurrentTool );
break;
}
}
} }
}
update(); update();
}
} }
...@@ -1407,7 +1414,7 @@ void GLViewer::processSelection( DisplayableInfo &dInfo, BaseSelectionProcessor ...@@ -1407,7 +1414,7 @@ void GLViewer::processSelection( DisplayableInfo &dInfo, BaseSelectionProcessor
if( proc.isDisplayableUpdateRequired() ) if( proc.isDisplayableUpdateRequired() )
{ {
updateDisplayable( m, proc.isSelectionResetRequired() ); updateDisplayable( m, proc.isSelectionResetRequired()? UpdateAll : UpdateAllButSelectionManagers );
updateSelectionZBuffer(); updateSelectionZBuffer();
} }
else if( proc.isSelectionResetRequired() ) else if( proc.isSelectionResetRequired() )
......
...@@ -363,13 +363,26 @@ public: ...@@ -363,13 +363,26 @@ public:
void populateDisplayerFactories( DisplayableFactoryInterface *plugin ); void populateDisplayerFactories( DisplayableFactoryInterface *plugin );
void populateDisplayerFactories( QList<DisplayableFactoryInterface*> &plugins ); void populateDisplayerFactories( QList<DisplayableFactoryInterface*> &plugins );
enum DisplayableUpdateRule
{
UpdateSelectionManagers = 1,
UpdateBoundingBox = 2,
UpdateTransform = 4,
UpdateDisplay = 8,
UpdateAll = UpdateSelectionManagers | UpdateBoundingBox | UpdateTransform | UpdateDisplay,
UpdateAllButSelectionManagers = UpdateBoundingBox | UpdateTransform | UpdateDisplay,
UpdateAllButBoundingBox = UpdateSelectionManagers | UpdateTransform | UpdateDisplay,
UpdateAllButTransform = UpdateSelectionManagers | UpdateBoundingBox | UpdateDisplay,
UpdateAllButDisplay = UpdateSelectionManagers | UpdateBoundingBox | UpdateTransform
};
inline bool isDisplayed( GenericUIData *m ) const { return m_Displayables.find(m) != m_Displayables.end(); } inline bool isDisplayed( GenericUIData *m ) const { return m_Displayables.find(m) != m_Displayables.end(); }
inline bool isAbleToDisplay( GenericUIData *m ) const { return m_Factories.find(m->GetTypeString()) != m_Factories.end(); } inline bool isAbleToDisplay( GenericUIData *m ) const { return m_Factories.find(m->GetTypeString()) != m_Factories.end(); }
inline DisplayableFactoryInterface* getFactory( const QString &type ) { FactoryMap::iterator f=m_Factories.find(type); return f==m_Factories.end()? NULL : f->second; } inline DisplayableFactoryInterface* getFactory( const QString &type ) { FactoryMap::iterator f=m_Factories.find(type); return f==m_Factories.end()? NULL : f->second; }
inline const DisplayableFactoryInterface* getFactory( const QString &type ) const { FactoryMap::const_iterator f=m_Factories.find(type); return f==m_Factories.end()? NULL : f->second; } inline const DisplayableFactoryInterface* getFactory( const QString &type ) const { FactoryMap::const_iterator f=m_Factories.find(type); return f==m_Factories.end()? NULL : f->second; }
inline DisplayableInterface* getDisplayable( const GenericUIData* m ) { DisplayableMap::iterator d=m_Displayables.find(m); return d==m_Displayables.end()? NULL : d->second.displayable; } inline DisplayableInterface* getDisplayable( const GenericUIData* m ) { DisplayableMap::iterator d=m_Displayables.find(m); return d==m_Displayables.end()? NULL : d->second.displayable; }
inline DisplayableInterface* getDisplayable( const GenericUIData* m ) const { DisplayableMap::const_iterator d=m_Displayables.find(m); return d==m_Displayables.end()? NULL : d->second.displayable; } inline DisplayableInterface* getDisplayable( const GenericUIData* m ) const { DisplayableMap::const_iterator d=m_Displayables.find(m); return d==m_Displayables.end()? NULL : d->second.displayable; }
virtual void updateDisplayable( GenericUIData *m, bool resetSelectionManagers = true ); virtual void updateDisplayable( GenericUIData *m, DisplayableUpdateRule updatesRequired = UpdateAll );
inline const DisplayableMap& getDisplayables() const { return m_Displayables; } inline const DisplayableMap& getDisplayables() const { return m_Displayables; }
inline DisplayableMap& getDisplayables() { return m_Displayables; } inline DisplayableMap& getDisplayables() { return m_Displayables; }
bool isDisplayableValid( DisplayableInterface *d ) const; bool isDisplayableValid( DisplayableInterface *d ) const;
......
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