// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-AddCursorCommand( TCursorCommand command, void* data )
+AddSlicesCommand( TCursorCommand command, void* data )
{
- this->m_CursorCommands.push_back(
+ this->m_SlicesCommands.push_back(
+ std::pair< TCursorCommand, void* >( command, data )
+ );
+ this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::ImageSliceActors::
+AddSeedCommand( TCursorCommand command, void* data )
+{
+ this->m_SeedCommands.push_back(
std::pair< TCursorCommand, void* >( command, data )
);
this->Modified( );
this->Modified( );
}
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::ImageSliceActors::
-SetSlicesCommand( TCursorCommand cmd, void* data )
-{
- this->SlicesCommand = cmd;
- this->SlicesData = data;
- this->Modified( );
-}
-
// -------------------------------------------------------------------------
vtkInteractorStyle* cpExtensions::Visualization::ImageSliceActors::
GetStyle( )
return;
// Update style
- if( force_style )
- {
- this->_ConfigureStyle( );
+ if( this->m_Style.GetPointer( ) != NULL && force_style )
rwi->SetInteractorStyle( this->m_Style );
- } // fi
-
// Update actors
-# error USE vtkActorCollection interface
- /* TODO
- for( unsigned int n = 0; n < this->GetNumberOfImageActors( ); ++n )
- renderer->AddActor( this->GetImageActor( n ) );
- renderer->AddActor( this->m_CursorActor );
- renderer->AddActor( this->m_PlaneActor );
- renderer->AddActor( this->m_TextActor );
- renderer->Modified( );
- */
+ vtkProp* prop;
+ this->InitTraversal( );
+ while( prop = this->GetNextProp( ) )
+ renderer->AddViewProp( prop );
+ renderer->Modified( );
// Configure camera
vtkCamera* camera = renderer->GetActiveCamera( );
if( renderer != NULL )
{
// Update actors
-# error USE vtkActorCollection interface
- /* TODO
- for( unsigned int n = 0; n < this->GetNumberOfImageActors( ); ++n )
- renderer->RemoveActor( this->GetImageActor( n ) );
- renderer->RemoveActor( this->m_CursorActor );
- renderer->RemoveActor( this->m_PlaneActor );
- renderer->RemoveActor( this->m_TextActor );
- renderer->Modified( );
- */
+ vtkProp* prop;
+ this->InitTraversal( );
+ while( prop = this->GetNextProp( ) )
+ renderer->RemoveViewProp( prop );
+ renderer->Modified( );
} // fi
if( rwi != NULL )
void cpExtensions::Visualization::ImageSliceActors::
SetInterpolate( bool v )
{
- if( this->Interpolate != v )
+ if( this->m_Interpolate != v )
{
for( unsigned int i = 0; i < this->m_ImageActors.size( ); ++i )
this->m_ImageActors[ i ]->SetInterpolate( v );
- this->Interpolate = v;
+ this->m_Interpolate = v;
this->Modified( );
} // fi
return( NULL );
}
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::ImageSliceActors::
+GetMinWindow( ) const
+{
+ return( this->m_MinWindow );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::ImageSliceActors::
+GetMaxWindow( ) const
+{
+ return( this->m_MaxWindow );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::ImageSliceActors::
+GetMinLevel( ) const
+{
+ return( this->m_MinLevel );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::ImageSliceActors::
+GetMaxLevel( ) const
+{
+ return( this->m_MaxLevel );
+}
+
// -------------------------------------------------------------------------
double cpExtensions::Visualization::ImageSliceActors::
GetWindow( ) const
{
- if( this->m_ImageMaps.size( ) > 0 )
- {
- if( this->m_ImageMaps[ 0 ].GetPointer( ) != NULL )
- {
- vtkWindowLevelLookupTable* lut =
- dynamic_cast< vtkWindowLevelLookupTable* >(
- this->m_ImageMaps[ 0 ]->GetLookupTable( )
- );
- if( lut != NULL )
- return( lut->GetWindow( ) );
- else
- return( double( 0 ) );
- }
- else
- return( double( 0 ) );
- }
+ if( this->m_ImageMaps.size( ) == 0 )
+ return( double( 0 ) );
+ if( this->m_ImageMaps[ 0 ].GetPointer( ) == NULL )
+ return( double( 0 ) );
+
+ vtkWindowLevelLookupTable* lut =
+ dynamic_cast< vtkWindowLevelLookupTable* >(
+ this->m_ImageMaps[ 0 ]->GetLookupTable( )
+ );
+ if( lut != NULL )
+ return( lut->GetWindow( ) );
else
return( double( 0 ) );
}
double cpExtensions::Visualization::ImageSliceActors::
GetLevel( ) const
{
- if( this->m_ImageMaps.size( ) > 0 )
- {
- if( this->m_ImageMaps[ 0 ].GetPointer( ) != NULL )
- {
- vtkWindowLevelLookupTable* lut =
- dynamic_cast< vtkWindowLevelLookupTable* >(
- this->m_ImageMaps[ 0 ]->GetLookupTable( )
- );
- if( lut != NULL )
- return( lut->GetLevel( ) );
- else
- return( double( 0 ) );
- }
- else
- return( double( 0 ) );
- }
+ if( this->m_ImageMaps.size( ) == 0 )
+ return( double( 0 ) );
+ if( this->m_ImageMaps[ 0 ].GetPointer( ) == NULL )
+ return( double( 0 ) );
+
+ vtkWindowLevelLookupTable* lut =
+ dynamic_cast< vtkWindowLevelLookupTable* >(
+ this->m_ImageMaps[ 0 ]->GetLookupTable( )
+ );
+ if( lut != NULL )
+ return( lut->GetLevel( ) );
else
return( double( 0 ) );
}
void cpExtensions::Visualization::ImageSliceActors::
SetWindow( double w )
{
- if( this->m_ImageMaps.size( ) > 0 )
- {
- if( this->m_ImageMaps[ 0 ].GetPointer( ) != NULL )
- {
- vtkWindowLevelLookupTable* lut =
- dynamic_cast< vtkWindowLevelLookupTable* >(
- this->m_ImageMaps[ 0 ]->GetLookupTable( )
- );
- if( lut != NULL )
- {
- /* TODO: Min and Max values are assigned 0!!!
- if( w < this->MinWindow )
- w = this->MinWindow;
- if( w > this->MaxWindow )
- w = this->MaxWindow;
- */
- lut->SetWindow( w );
- lut->Build( );
- this->m_ImageMaps[ 0 ]->Modified( );
- this->Modified( );
-
- } // fi
-
- } // fi
+ if( this->m_ImageMaps.size( ) == 0 )
+ return;
+ if( this->m_ImageMaps[ 0 ].GetPointer( ) == NULL )
+ return;
+ vtkWindowLevelLookupTable* lut =
+ dynamic_cast< vtkWindowLevelLookupTable* >(
+ this->m_ImageMaps[ 0 ]->GetLookupTable( )
+ );
+ if( lut == NULL )
+ return;
- } // fi
+ /* TODO: Min and Max values are assigned 0!!!
+ if( w < this->MinWindow )
+ w = this->MinWindow;
+ if( w > this->MaxWindow )
+ w = this->MaxWindow;
+ */
+ lut->SetWindow( w );
+ lut->Build( );
+ this->m_ImageMaps[ 0 ]->Modified( );
+ this->Modified( );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
SetLevel( double l )
{
- if( this->m_ImageMaps.size( ) > 0 )
- {
- if( this->m_ImageMaps[ 0 ].GetPointer( ) != NULL )
- {
- vtkWindowLevelLookupTable* lut =
- dynamic_cast< vtkWindowLevelLookupTable* >(
- this->m_ImageMaps[ 0 ]->GetLookupTable( )
- );
- if( lut != NULL )
- {
- /* TODO: Min and Max values are assigned 0!!!
- if( l < this->MinLevel )
- l = this->MinLevel;
- if( l > this->MaxLevel )
- l = this->MaxLevel;
- */
- lut->SetLevel( l );
- lut->Build( );
- this->m_ImageMaps[ 0 ]->Modified( );
- this->Modified( );
-
- } // fi
-
- } // fi
+ if( this->m_ImageMaps.size( ) == 0 )
+ return;
+ if( this->m_ImageMaps[ 0 ].GetPointer( ) == NULL )
+ return;
+ vtkWindowLevelLookupTable* lut =
+ dynamic_cast< vtkWindowLevelLookupTable* >(
+ this->m_ImageMaps[ 0 ]->GetLookupTable( )
+ );
+ if( lut == NULL )
+ return;
- } // fi
+ /* TODO: Min and Max values are assigned 0!!!
+ if( l < this->MinLevel )
+ l = this->MinLevel;
+ if( l > this->MaxLevel )
+ l = this->MaxLevel;
+ */
+ lut->SetLevel( l );
+ lut->Build( );
+ this->m_ImageMaps[ 0 ]->Modified( );
+ this->Modified( );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
SetWindowLevel( double w, double l )
{
- if( this->m_ImageMaps.size( ) > 0 )
- {
- if( this->m_ImageMaps[ 0 ].GetPointer( ) != NULL )
- {
- vtkWindowLevelLookupTable* lut =
- dynamic_cast< vtkWindowLevelLookupTable* >(
- this->m_ImageMaps[ 0 ]->GetLookupTable( )
- );
- if( lut != NULL )
- {
- /* TODO: Min and Max values are assigned 0!!!
- std::cout << this->MinWindow << " " << this->MaxWindow << std::endl;
- std::cout << this->MinLevel << " " << this->MaxLevel << std::endl;
- std::cout << w << " " << l << " <-> " << std::ends;
- if( w < this->MinWindow )
- w = this->MinWindow;
- if( w > this->MaxWindow )
- w = this->MaxWindow;
- if( l < this->MinLevel )
- l = this->MinLevel;
- if( l > this->MaxLevel )
- l = this->MaxLevel;
- std::cout << w << " " << l << std::endl;
- */
- lut->SetWindow( w );
- lut->SetLevel( l );
- lut->Build( );
- this->m_ImageMaps[ 0 ]->Modified( );
- this->Modified( );
-
- } // fi
-
- } // fi
+ if( this->m_ImageMaps.size( ) == 0 )
+ return;
+ if( this->m_ImageMaps[ 0 ].GetPointer( ) == NULL )
+ return;
+ vtkWindowLevelLookupTable* lut =
+ dynamic_cast< vtkWindowLevelLookupTable* >(
+ this->m_ImageMaps[ 0 ]->GetLookupTable( )
+ );
+ if( lut == NULL )
+ return;
- } // fi
+ /* TODO: Min and Max values are assigned 0!!!
+ if( w < this->MinWindow )
+ w = this->MinWindow;
+ if( w > this->MaxWindow )
+ w = this->MaxWindow;
+ if( l < this->MinLevel )
+ l = this->MinLevel;
+ if( l > this->MaxLevel )
+ l = this->MaxLevel;
+ */
+ lut->SetWindow( w );
+ lut->SetLevel( l );
+ lut->Build( );
+ this->m_ImageMaps[ 0 ]->Modified( );
+ this->UpdateText( w, l );
+ this->Modified( );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
ResetWindowLevel( )
{
+ static const double _2 = double( 2 );
this->SetWindowLevel(
- this->MaxWindow,
- ( this->MaxLevel + this->MinLevel ) / double( 2 )
+ this->m_MaxWindow, ( this->m_MaxLevel + this->m_MinLevel ) / _2
);
}
void cpExtensions::Visualization::ImageSliceActors::
UpdateText( double pos[ 3 ] )
{
- /* TODO
if( this->m_SliceMappers.size( ) > 0 )
{
char axis;
this->m_TextActor->SetInput( this->m_TextBuffer );
this->m_TextActor->Modified( );
this->Modified( );
- */
}
// -------------------------------------------------------------------------
cpExtensions::Visualization::ImageSliceActors::
ImageSliceActors( )
: Superclass( ),
- Interpolate( false )
+ m_Interpolate( false )
{
this->Clear( );
-
- this->SlicesCommand = NULL;
+ this->_ConfigureStyle( );
}
// -------------------------------------------------------------------------
lut->Build( );
this->m_ImageMaps[ 0 ]->SetLookupTable( lut );
- this->MinWindow = double( 0 );
- this->MaxWindow = range[ 1 ] - range[ 0 ];
- this->MinLevel = range[ 0 ];
- this->MaxLevel = range[ 1 ];
+ this->m_MinWindow = double( 0 );
+ this->m_MaxWindow = range[ 1 ] - range[ 0 ];
+ this->m_MinLevel = range[ 0 ];
+ this->m_MaxLevel = range[ 1 ];
}
else
this->SetLookupTableAsColor( nImgs, 1, 0, 0 );
vtkSmartPointer< vtkImageActor >::New( );
this->m_ImageActors.push_back( actor );
actor->SetMapper( mapper );
- actor->SetInterpolate( this->Interpolate );
+ actor->SetInterpolate( this->m_Interpolate );
actor->Modified( );
if( nImages == 0 )
if( nImages > 1 )
this->SetSliceNumber( this->GetSliceNumber( ) );
+ else
+ this->SetSliceNumber( this->GetSliceNumberMaxValue( ) );
this->Modified( );
}
if( btn == ImageInteractorStyle::ButtonID_None )
{
+ actors->SetCursor( pos );
actors->UpdateText( pos );
+ actors->GetStyle( )->GetInteractor( )->Render( );
}
else if( btn == ImageInteractorStyle::ButtonID_Left )
{
- if( !alt && ctr && !sft && actors->SlicesCommand != NULL )
- actors->SlicesCommand( pos, actors->GetAxis( ), actors->SlicesData );
+ unsigned int nC = actors->m_SlicesCommands.size( );
+ if( !alt && ctr && !sft && nC > 0 )
+ {
+ for( unsigned int i = 0; i < nC; ++i )
+ actors->m_SlicesCommands[ i ].first(
+ pos, actors->GetAxis( ), actors->m_SlicesCommands[ i ].second
+ );
+ actors->GetStyle( )->GetInteractor( )->Render( );
+
+ } // fi
}
else if( btn == ImageInteractorStyle::ButtonID_Middle )
{
int a0 = actors->GetAxis( );
int a1 = ( a0 + 1 ) % 3;
int a2 = ( a0 + 2 ) % 3;
- double dx = pos[ a1 ] - actors->StartWindowLevelPos[ a1 ];
- double dy = pos[ a2 ] - actors->StartWindowLevelPos[ a2 ];
+ double dx = pos[ a1 ] - actors->m_StartWindowLevelPos[ a1 ];
+ double dy = pos[ a2 ] - actors->m_StartWindowLevelPos[ a2 ];
dx /= bounds[ ( a1 << 1 ) + 1 ] - bounds[ a1 << 1 ];
dy /= bounds[ ( a2 << 1 ) + 1 ] - bounds[ a2 << 1 ];
- dx *= actors->StartWindowLevel[ 0 ];
- dy *= actors->StartWindowLevel[ 1 ];
+ dx *= actors->m_StartWindowLevel[ 0 ];
+ dy *= actors->m_StartWindowLevel[ 1 ];
actors->SetWindowLevel(
- actors->StartWindowLevel[ 0 ] + dx,
- actors->StartWindowLevel[ 1 ] + dy
+ actors->m_StartWindowLevel[ 0 ] + dx,
+ actors->m_StartWindowLevel[ 1 ] + dy
);
+ actors->GetStyle( )->GetInteractor( )->Render( );
} // fi
if( actors == NULL )
return;
- actors->StartWindowLevelPos[ 0 ] = pos[ 0 ];
- actors->StartWindowLevelPos[ 1 ] = pos[ 1 ];
- actors->StartWindowLevelPos[ 2 ] = pos[ 2 ];
- actors->StartWindowLevel[ 0 ] = actors->GetWindow( );
- actors->StartWindowLevel[ 1 ] = actors->GetLevel( );
+ actors->m_StartWindowLevelPos[ 0 ] = pos[ 0 ];
+ actors->m_StartWindowLevelPos[ 1 ] = pos[ 1 ];
+ actors->m_StartWindowLevelPos[ 2 ] = pos[ 2 ];
+ actors->m_StartWindowLevel[ 0 ] = actors->GetWindow( );
+ actors->m_StartWindowLevel[ 1 ] = actors->GetLevel( );
}
// -------------------------------------------------------------------------
if( btn == ImageInteractorStyle::ButtonID_Left )
{
- if( !alt && !ctr && !sft )
- actors->SetCursor( pos );
- else if( !alt && ctr && !sft && actors->SlicesCommand != NULL )
+ unsigned int nC = actors->m_SeedCommands.size( );
+ if( !alt && ctr && !sft && nC > 0 )
{
- actors->SlicesCommand( pos, actors->GetAxis( ), actors->SlicesData );
- for( unsigned int i = 0; i < actors->m_CursorCommands.size( ); ++i )
- actors->m_CursorCommands[ i ].first(
- pos,
- actors->GetAxis( ),
- actors->m_CursorCommands[ i ].second
+ for( unsigned int i = 0; i < nC; ++i )
+ actors->m_SeedCommands[ i ].first(
+ pos, actors->GetAxis( ), actors->m_SeedCommands[ i ].second
);
+ actors->GetStyle( )->GetInteractor( )->Render( );
} // fi
}
if( !alt && !ctr && !sft )
{
actors->SetSliceNumber( actors->GetSliceNumber( ) + dir );
+ actors->GetStyle( )->GetInteractor( )->Render( );
}
else if( !alt && !ctr && sft )
{
actors->SetSliceNumber( actors->GetSliceNumber( ) + ( dir * 10 ) );
+ actors->GetStyle( )->GetInteractor( )->Render( );
} // fi
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageSliceActors::
-_KeyCommand(
- void* data,
- const char& key
- )
+_KeyCommand( void* data, const char& key )
{
}