Commit be320e35 authored by Stéphane Albert's avatar Stéphane Albert

ENH: Optimized ImageViewWidget::mouseMoveEvent().

parent b74d1eb6
......@@ -221,6 +221,9 @@ public:
/**
*/
inline bool IsGLSLEnabled() const;
/**
*/
virtual bool IsEffectsEnabled() const = 0;
/**
*/
inline bool ZoomToRegion( const PointType & origin,
......
......@@ -1090,6 +1090,14 @@ ImageViewRenderer
m_GlView->SaveScreenshot( QFile::encodeName( filename ).constData() );
}
/*****************************************************************************/
bool
ImageViewRenderer
::IsEffectsEnabled() const
{
return m_EffectsEnabled;
}
/*****************************************************************************/
/* SLOTS */
/*****************************************************************************/
......
......@@ -194,6 +194,8 @@ public:
const PointType & vcenter,
const SpacingType & vspacing ) const;
virtual bool IsEffectsEnabled() const;
/*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/
// public slots
......
......@@ -732,16 +732,89 @@ ImageViewWidget
// Superclass default behaviour.
QGLWidget::mouseMoveEvent( event );
// Delegate behaviour.
m_Manipulator->MouseMoveEvent( event );
//
// Get layer-stack.
StackedLayerModel * stackedLayerModel = GetLayerStack();
assert( stackedLayerModel!=NULL );
//
// Update view depending on shader status special behaviour.
//
bool isAnyEffectActive = false;
if( m_Renderer->IsEffectsEnabled() )
{
for( StackedLayerModel::ConstIterator it( stackedLayerModel->Begin() );
it!=stackedLayerModel->End();
++ it )
{
assert( it->second!=NULL );
if( it->second->inherits( AbstractImageModel::staticMetaObject.className() ) )
{
VectorImageModel * imageModel = qobject_cast< VectorImageModel * >( it->second );
assert( imageModel!=NULL );
if( imageModel->GetSettings().GetEffect()!=EFFECT_NONE &&
imageModel->GetSettings().GetEffect()!=EFFECT_NORMAL )
{
#if USE_XP_REGION_OPTIM
PointType origin;
PointType extent;
m_Renderer->GetLayerExtent( it->first, origin, extent );
if( ( origin[ 0 ]<=ptView[ 0 ] && ptView[ 0 ]<=extent[ 0 ] &&
origin[ 1 ]<=ptView[ 1 ] && ptView[ 1 ]<=extent[ 1 ] ) ||
( origin[ 0 ]<=m_Position[ 0 ] && m_Position[ 0 ]<=extent[ 0 ] &&
origin[ 1 ]<=m_Position[ 1 ] && m_Position[ 1 ]<=extent[ 1 ] ) )
{
qDebug() << FromStdString( it->first );
// qDebug()
// << "x:" << origin[ 0 ] << ptView[ 0 ] << m_Position[ 0 ] << extent[ 0 ];
// qDebug()
// << "y:" << origin[ 1 ] << ptView[ 1 ] << m_Position[ 1 ] << extent[ 1 ];
// qDebug()
// << "x:" << ptView[ 0 ] << m_Position[ 0 ];
// qDebug()
// << "y:" << ptView[ 1 ] << m_Position[ 1 ];
#endif // USE_XP_REGION_OPTIM
// qDebug() << "updateGL(" << in[ 0 ] << "," << in[ 1 ] << ")";
isAnyEffectActive = true;
break;
}
#if USE_XP_REGION_OPTIM
}
#endif // USE_XP_REGION_OPTIM
}
}
#if USE_XP_REGION_OPTIM
m_Position = ptView;
#endif // USE_XP_REGION_OPTION
}
// Delegate behaviour.
if( isAnyEffectActive )
{
bool bypass = m_Renderer->SetBypassRenderingEnabled( true );
m_Manipulator->MouseMoveEvent( event );
m_Renderer->SetBypassRenderingEnabled( bypass );
}
else
m_Manipulator->MouseMoveEvent( event );
// assert( stackedLayerModel!=NULL );
if( stackedLayerModel==NULL )
return;
//
// Pixel-picking special behaviour.
......@@ -788,7 +861,7 @@ ImageViewWidget
DefaultImageType::PixelType()
);
}
else
else if( isAnyEffectActive )
{
// Transform coordinates from widget space to viewport space.
assert( m_Manipulator!=NULL );
......@@ -807,67 +880,8 @@ ImageViewWidget
m_Renderer->UpdatePixelInfo( event->pos(), ptView, pixels );
}
//
// Update view depending on shader status special behaviour.
//
{
for( StackedLayerModel::ConstIterator it( stackedLayerModel->Begin() );
it!=stackedLayerModel->End();
++ it )
{
assert( it->second!=NULL );
if( it->second->inherits( AbstractImageModel::staticMetaObject.className() ) )
{
VectorImageModel * imageModel = qobject_cast< VectorImageModel * >( it->second );
assert( imageModel!=NULL );
if( imageModel->GetSettings().GetEffect()!=EFFECT_NONE &&
imageModel->GetSettings().GetEffect()!=EFFECT_NORMAL )
{
#if USE_XP_REGION_OPTIM
PointType origin;
PointType extent;
m_Renderer->GetLayerExtent( it->first, origin, extent );
if( ( origin[ 0 ]<=ptView[ 0 ] && ptView[ 0 ]<=extent[ 0 ] &&
origin[ 1 ]<=ptView[ 1 ] && ptView[ 1 ]<=extent[ 1 ] ) ||
( origin[ 0 ]<=m_Position[ 0 ] && m_Position[ 0 ]<=extent[ 0 ] &&
origin[ 1 ]<=m_Position[ 1 ] && m_Position[ 1 ]<=extent[ 1 ] ) )
{
qDebug() << FromStdString( it->first );
// qDebug()
// << "x:" << origin[ 0 ] << ptView[ 0 ] << m_Position[ 0 ] << extent[ 0 ];
// qDebug()
// << "y:" << origin[ 1 ] << ptView[ 1 ] << m_Position[ 1 ] << extent[ 1 ];
// qDebug()
// << "x:" << ptView[ 0 ] << m_Position[ 0 ];
// qDebug()
// << "y:" << ptView[ 1 ] << m_Position[ 1 ];
#endif // USE_XP_REGION_OPTIM
// qDebug() << "updateGL(" << in[ 0 ] << "," << in[ 1 ] << ")";
updateGL();
break;
}
#if USE_XP_REGION_OPTIM
}
#endif // USE_XP_REGION_OPTIM
}
}
#if USE_XP_REGION_OPTIM
m_Position = ptView;
#endif // USE_XP_REGION_OPTION
}
if( isAnyEffectActive )
updateGL();
}
/*******************************************************************************/
......
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