void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
OnMouseMove( )
{
+ if( this->m_MPRActors == NULL )
+ return;
+
double pos[ 3 ];
- if( this->CursorMoving && this->m_MPRActors != NULL )
+ if( this->CursorMoving )
{
bool picked = this->_PickPosition( pos );
if( picked )
this->_RenderAssociateInteractors( );
} // fi
+ }
+ else
+ {
+ switch( this->State )
+ {
+ case VTKIS_WINDOW_LEVEL:
+ this->WindowLevel( );
+ break;
+ case VTKIS_DOLLY:
+ this->Dolly( );
+ break;
+ case VTKIS_PAN:
+ this->Pan( );
+ break;
+ } // hctiws
} // fi
}
this->FindPokedRenderer( x, y );
if( this->CurrentRenderer == NULL )
return;
-
- // Redefine this button to handle window/level
this->GrabFocus( this->EventCallbackCommand );
if( this->Interactor->GetControlKey( ) )
OnLeftButtonUp( )
{
if( this->CursorMoving )
+ {
this->EndCursorMoving( );
+ if( this->Interactor )
+ this->ReleaseFocus( );
+
+ } // fi
}
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
OnMiddleButtonDown( )
{
- std::cout << "middown" << std::endl;
+ int x = this->Interactor->GetEventPosition( )[ 0 ];
+ int y = this->Interactor->GetEventPosition( )[ 1 ];
+
+ this->FindPokedRenderer( x, y );
+ if( this->CurrentRenderer == NULL )
+ return;
+ this->GrabFocus( this->EventCallbackCommand );
+
+ if( this->Interactor->GetAltKey( ) )
+ {
+ }
+ else if( this->Interactor->GetControlKey( ) )
+ {
+ }
+ else if( this->Interactor->GetShiftKey( ) )
+ {
+ }
+ else
+ this->StartPan( );
}
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
OnMiddleButtonUp( )
{
- std::cout << "midup" << std::endl;
+ switch( this->State )
+ {
+ case VTKIS_PAN:
+ this->EndPan( );
+ break;
+ } // hctiws
}
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
OnRightButtonDown( )
{
- std::cout << "ridown" << std::endl;
+ int x = this->Interactor->GetEventPosition( )[ 0 ];
+ int y = this->Interactor->GetEventPosition( )[ 1 ];
+
+ this->FindPokedRenderer( x, y );
+ if( this->CurrentRenderer == NULL )
+ return;
+ this->GrabFocus( this->EventCallbackCommand );
+
+ if( this->Interactor->GetControlKey( ) )
+ {
+ this->WindowLevelStartPosition[ 0 ] = x;
+ this->WindowLevelStartPosition[ 1 ] = y;
+ this->StartWindowLevel( );
+ }
+ else
+ {
+ this->StartDolly( );
+ } // fi
}
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
OnRightButtonUp( )
{
- std::cout << "riup" << std::endl;
+ switch( this->State )
+ {
+ case VTKIS_WINDOW_LEVEL:
+ {
+ this->EndWindowLevel( );
+ if( this->Interactor )
+ this->ReleaseFocus( );
+ }
+ break;
+ case VTKIS_DOLLY:
+ this->EndDolly( );
+ break;
+ } // hctiws
}
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
OnChar( )
{
- std::cout << "char" << std::endl;
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
-Rotate( )
-{
- std::cout << "Rotate" << std::endl;
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
-Pan( )
-{
- std::cout << "pan" << std::endl;
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
-Spin( )
-{
- std::cout << "spin" << std::endl;
-}
+ switch( this->Interactor->GetKeyCode( ) )
+ {
+ case 'r': case 'R':
+ {
+ vtkRenderer* ren =
+ this->Interactor->GetRenderWindow( )->
+ GetRenderers( )->GetFirstRenderer( );
+ if( ren != NULL )
+ ren->ResetCamera( );
+ this->Interactor->Render( );
+ }
+ break;
+ case 'w': case 'W': case 'l': case 'L':
+ {
+ if( this->m_MPRActors != NULL )
+ {
+ this->m_MPRActors->ResetWindowLevel( );
+ this->Interactor->Render( );
+ this->_RenderAssociateInteractors( );
-// -------------------------------------------------------------------------
-void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
-Zoom( )
-{
- std::cout << "Zoom" << std::endl;
+ } // fi
+ }
+ break;
+ } // hctiws
}
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
WindowLevel( )
{
- std::cout << "wl" << std::endl;
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
-Pick( )
-{
- std::cout << "Pick" << std::endl;
-}
+ if( this->Mode == Self::NavigationMode )
+ {
+ if( this->Interactor == NULL )
+ return;
+ vtkRenderer* ren =
+ this->Interactor->GetRenderWindow( )->
+ GetRenderers( )->GetFirstRenderer( );
+ if( ren == NULL )
+ return;
+
+ // Compute scales
+ this->WindowLevelCurrentPosition[ 0 ] =
+ this->Interactor->GetEventPosition( )[ 0 ];
+ this->WindowLevelCurrentPosition[ 1 ] =
+ this->Interactor->GetEventPosition( )[ 1 ];
+ int* size = ren->GetSize( );
+ double sw = double(
+ this->WindowLevelCurrentPosition[ 0 ] -
+ this->WindowLevelStartPosition[ 0 ]
+ ) / double( size[ 0 ] );
+ double sl = (
+ this->WindowLevelStartPosition[ 1 ] -
+ this->WindowLevelCurrentPosition[ 1 ]
+ ) / double( size[ 1 ] );
+
+ double w = this->WindowLevelInitial[ 0 ] * ( double( 1 ) + sw );
+ double l = this->WindowLevelInitial[ 1 ] * ( double( 1 ) + sl );
+ double minw = this->m_MPRActors->GetMinWindow( );
+ double maxw = this->m_MPRActors->GetMaxWindow( );
+ double minl = this->m_MPRActors->GetMinLevel( );
+ double maxl = this->m_MPRActors->GetMaxLevel( );
+
+ if( w < minw ) w = minw;
+ if( maxw < w ) w = maxw;
+ if( l < minl ) l = minl;
+ if( maxl < l ) l = maxl;
+
+ this->m_MPRActors->SetWindowLevel( w, l );
+ this->Interactor->Render( );
+ this->_RenderAssociateInteractors( );
+ }
+ else if( this->Mode == Self::DeformationMode )
+ {
+ // TODO
-// -------------------------------------------------------------------------
-void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
-Slice( )
-{
- std::cout << "Slice" << std::endl;
+ } // fi
}
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
StartWindowLevel( )
{
- std::cout << "swl" << std::endl;
-}
-
-// -------------------------------------------------------------------------
-void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
-EndWindowLevel( )
-{
- std::cout << "ewl" << std::endl;
-}
+ if( this->State != VTKIS_NONE )
+ return;
+ if( this->Mode == Self::NavigationMode )
+ {
+ this->StartState( VTKIS_WINDOW_LEVEL );
-// -------------------------------------------------------------------------
-void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
-StartPick( )
-{
- std::cout << "sp" << std::endl;
-}
+ this->WindowLevelInitial[ 0 ] = this->m_MPRActors->GetWindow( );
+ this->WindowLevelInitial[ 1 ] = this->m_MPRActors->GetLevel( );
+ }
+ else if( this->Mode == Self::DeformationMode )
+ {
+ // TODO
-// -------------------------------------------------------------------------
-void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
-EndPick( )
-{
- std::cout << "ep" << std::endl;
+ } // fi
}
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
-StartSlice( )
+EndWindowLevel( )
{
- std::cout << "ss" << std::endl;
-}
+ if( this->Mode == Self::NavigationMode )
+ {
+ if( this->State != VTKIS_WINDOW_LEVEL )
+ return;
+ this->StopState( );
+ }
+ else
+ {
+ // TODO
-// -------------------------------------------------------------------------
-void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
-EndSlice( )
-{
- std::cout << "es" << std::endl;
+ } // fi
}
// -------------------------------------------------------------------------