-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-_ConfigureInput( int orientation )
-{
- // Prepare main image
- this->m_Mapper->SetOrientation( orientation );
- this->m_Mapper->Update( );
- this->m_Actor->GetProperty( )->SetOpacity( 0.8 );
- this->m_Actor->Modified( );
- auto st = this->GetStyle( );
- if( st != NULL )
- st->AssociateImageActor( this->m_Actor );
- this->AddItem( this->m_Actor );
-
- // Prepare main cursor
- this->_ConfigureCursor( );
- this->AddItem( this->m_Cursor.Actor );
-
- // Prepare window/level
- if( !( this->m_ManualScalarRange ) )
- this->UnsetScalarRange( );
-
- // Add all other actors
- this->AddItem( this->m_TextActor );
-
- // Put it in the first slice
- auto image = this->m_Mapper->GetInput( );
- int ext[ 6 ];
- image->GetExtent( ext );
- this->SetSliceNumber( ext[ orientation << 1 ] );
-
- /*
- if( this->m_Style.GetPointer( ) != NULL )
- this->AddItem( this->m_Actor );
-
- this->SetSliceNumber( this->GetSliceNumberMinValue( ) );
- this->ResetCursor( );
- this->Modified( );
-
- // Reset cursors
- this->ResetCursor( );
- this->ResetAxesCursor( );
-
- // Update window/level ranges
- vtkImageData* data = this->GetInputImage( );
- if( data != NULL )
- {
- double r[ 2 ];
- data->GetScalarRange( r );
- this->m_WLRange[ 0 ] = double( 0 );
- this->m_WLRange[ 1 ] = r[ 1 ] - r[ 0 ];
- this->m_WLRange[ 2 ] = r[ 0 ];
- this->m_WLRange[ 3 ] = r[ 1 ];
- this->ResetWindowLevel( );
-
- // Configure blender
- this->m_BlenderBase = vtkSmartPointer< vtkImageData >::New( );
- this->m_BlenderBase->ShallowCopy( data );
- this->m_BlenderBase->AllocateScalars( VTK_UNSIGNED_CHAR, 1 );
- std::memset(
- this->m_BlenderBase->GetScalarPointer( ), 0,
- this->m_BlenderBase->GetActualMemorySize( )
- );
- this->m_Blender->AddInputData( this->m_BlenderBase );
-
- } // fi
- */
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-_ConfigureCursor( )
-{
- int a = this->m_Mapper->GetOrientation( );
- double bounds[ 6 ];
- this->m_Actor->GetBounds( bounds );
- bounds[ a << 1 ] += 1e-5;
- bounds[ ( a << 1 ) + 1 ] += 1e-5;
-
- this->m_Cursor.Source->SetModelBounds( bounds );
- this->m_Cursor.Source->AllOn( );
- this->m_Cursor.Actor->GetProperty( )->SetOpacity( 1 );
- this->m_Cursor.Actor->GetProperty( )->SetLineWidth( 3 );
- this->m_Cursor.Modified( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-_MouseMoveCommand(
- void* data,
- const TStyle::ButtonID& btn,
- int* idx, double* pos,
- bool alt, bool ctr, bool sft
- )
-{
- ImageSliceActors* self = reinterpret_cast< ImageSliceActors* >( data );
- if( self == NULL )
- return;
-
- if( btn == TStyle::ButtonID_None )
- {
- self->ShowPixelText( pos );
- self->m_Cursor.Source->SetFocalPoint( pos );
- self->m_Cursor.Source->Modified( );
- self->m_Cursor.Modified( );
- self->Render( );
- }
- else if( btn == TStyle::ButtonID_Right )
- {
- if( !alt && !ctr && sft )
- {
- int a0 = self->m_Mapper->GetOrientation( );
- int a1 = ( a0 + 1 ) % 3;
- int a2 = ( a0 + 2 ) % 3;
- double dx = pos[ a1 ] - self->m_StartMouseEvent[ a1 ];
- double dy = pos[ a2 ] - self->m_StartMouseEvent[ a2 ];
- double bounds[ 6 ];
- self->m_Actor->GetBounds( bounds );
- dx /= bounds[ ( a1 << 1 ) + 1 ] - bounds[ a1 << 1 ];
- dy /= bounds[ ( a2 << 1 ) + 1 ] - bounds[ a2 << 1 ];
- double w = self->m_StartWindow + dx;
- double l = self->m_StartLevel + dy;
-
- self->SetWindowLevel( w, l );
- self->Render( );
- for(
- auto aIt = self->m_AssociatedSlices.begin( );
- aIt != self->m_AssociatedSlices.end( );
- ++aIt
- )
- {
- ( *aIt )->SetWindowLevel( w, l );
- ( *aIt )->Render( );
-
- } // rof
-
- } // fi
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-_MouseClickCommand(
- void* data,
- const TStyle::ButtonID& btn,
- int* idx, double* pos,
- bool alt, bool ctr, bool sft
- )
-{
- ImageSliceActors* self = reinterpret_cast< ImageSliceActors* >( data );
- if( self == NULL )
- return;
-
- self->m_StartMouseEvent[ 0 ] = pos[ 0 ];
- self->m_StartMouseEvent[ 1 ] = pos[ 1 ];
- self->m_StartMouseEvent[ 2 ] = pos[ 2 ];
-
- if( btn == TStyle::ButtonID_Right )
- {
- if( !alt && !ctr && sft )
- {
- double r[ 2 ];
- self->GetScalarRange( r );
- double d = r[ 1 ] - r[ 0 ];
- self->m_StartWindow = self->GetWindow( ) / d;
- self->m_StartLevel = ( self->GetLevel( ) - r[ 0 ] ) / d;
-
- } // fi
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-_MouseWheelCommand(
- void* data,
- const int& dir, bool alt, bool ctr, bool sft
- )
-{
- ImageSliceActors* self = reinterpret_cast< ImageSliceActors* >( data );
- if( self == NULL )
- return;
- auto ren = self->m_Style->GetCurrentRenderer( );
- if( ren == NULL )
- return;
- auto cam = ren->GetActiveCamera( );
- if( cam == NULL )
- return;
- auto win = ren->GetRenderWindow( );
- if( win == NULL )
- return;
-
- // Get previous values
- int a = self->m_Mapper->GetOrientation( );
- double bounds[ 6 ];
- self->m_Actor->GetBounds( bounds );
- double prev_pos = bounds[ a << 1 ];
-
- // Move slice
- long slice = self->GetSliceNumber( ) + dir * ( ( sft )? 10: 1 );
- self->SetSliceNumber( slice );
- self->m_Actor->GetBounds( bounds );
-
- // Reset camera
- double cam_pos[ 3 ];
- cam->GetPosition( cam_pos );
- cam_pos[ a ] += bounds[ a << 1 ] - prev_pos;
- cam->SetPosition( cam_pos );
-
- // Update text
- self->ShowPixelText( self->m_Cursor.Source->GetFocalPoint( ) );
-
- // Update all
- win->Render( );
- for(
- auto aIt = self->m_AssociatedSlices.begin( );
- aIt != self->m_AssociatedSlices.end( );
- ++aIt
- )
- {
- if( ( *aIt )->m_Mapper->GetOrientation( ) == a )
- {
- ( *aIt )->SetSliceNumber( slice );
- ( *aIt )->Render( );
-
- } // fi
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-_KeyCommand(
- void* data,
- const char& key
- )
-{
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-_EnterCommand( void* data )
-{
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-_LeaveCommand( void* data )
-{
-}
-