X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FVisualization%2FImageViewerActors.cxx;fp=lib%2FcpExtensions%2FVisualization%2FImageViewerActors.cxx;h=0000000000000000000000000000000000000000;hb=2e142df11d6f312a2a2b5097b8da73571ed523e8;hp=65114c8b74d607b96f872579052f68b7943e3222;hpb=61b3659afe961ed248f30e26f9ca8f28fcfafddc;p=cpPlugins.git diff --git a/lib/cpExtensions/Visualization/ImageViewerActors.cxx b/lib/cpExtensions/Visualization/ImageViewerActors.cxx deleted file mode 100644 index 65114c8..0000000 --- a/lib/cpExtensions/Visualization/ImageViewerActors.cxx +++ /dev/null @@ -1,169 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -cpExtensions::Visualization::ImageViewerActors:: -Self* cpExtensions::Visualization::ImageViewerActors:: -New( ) -{ - return( new Self( ) ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::Visualization::ImageViewerActors:: -SetImage( vtkImageData* image, int orientation ) -{ - this->Superclass::SetImage( image, orientation ); - - this->m_Cursor = vtkSmartPointer< CursorActors >::New( ); - this->m_Cursor->SetImageBounds( image->GetBounds( ) ); - this->m_Cursor->SetImageOrientation( orientation ); - this->m_Cursor->GetProperty( 0 )->SetColor( 1, 1, 0 ); - this->m_Cursor->GetProperty( 1 )->SetColor( 1, 1, 0 ); - this->m_Cursor->GetProperty( 0 )->SetLineWidth( 1.5 ); - this->m_Cursor->GetProperty( 1 )->SetLineWidth( 1.5 ); - this->m_Cursor->VisibilityOff( ); - - this->m_SuperCursor = vtkSmartPointer< CursorActors >::New( ); - this->m_SuperCursor->SetImageBounds( image->GetBounds( ) ); - this->m_SuperCursor->SetImageOrientation( orientation ); - this->m_SuperCursor->GetProperty( 0 )->SetColor( 0, 1, 1 ); - this->m_SuperCursor->GetProperty( 1 )->SetColor( 0, 1, 1 ); - this->m_SuperCursor->GetProperty( 0 )->SetLineWidth( 1.5 ); - this->m_SuperCursor->GetProperty( 1 )->SetLineWidth( 1.5 ); - this->m_SuperCursor->VisibilityOff( ); - - // Prepare text - this->m_TextBuffer[ 0 ] = '\0'; - this->m_Text = vtkSmartPointer< vtkTextActor >::New( ); - this->m_Text->SetTextScaleModeToNone( ); - auto textprop = this->m_Text->GetTextProperty( ); - textprop->SetColor( 1, 1, 0 ); - textprop->SetFontFamilyToCourier( ); - textprop->SetFontSize( 18 ); - textprop->BoldOff( ); - textprop->ItalicOff( ); - textprop->ShadowOff( ); - textprop->SetJustificationToLeft( ); - textprop->SetVerticalJustificationToBottom( ); - auto coord = this->m_Text->GetPositionCoordinate( ); - coord->SetCoordinateSystemToNormalizedViewport( ); - coord->SetValue( 0.01, 0.05 ); - this->m_Text->VisibilityOff( ); - - // Update actor list - this->m_Cursor->InitTraversal( ); - while( vtkProp* prop = this->m_Cursor->GetNextProp( ) ) - this->AddItem( prop ); - this->m_SuperCursor->InitTraversal( ); - while( vtkProp* prop = this->m_SuperCursor->GetNextProp( ) ) - this->AddItem( prop ); - this->AddItem( this->m_Text ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::Visualization::ImageViewerActors:: -SetCursor( double* pos, bool neg ) -{ - this->m_Cursor->SetCursor( pos, neg ); - this->_ShowText( pos ); - this->m_Cursor->VisibilityOn( ); - this->m_Text->VisibilityOn( ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::Visualization::ImageViewerActors:: -SetSuperCursor( double* pos, bool neg ) -{ - this->SetCursor( pos, neg ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::Visualization::ImageViewerActors:: -HideViewerActors( ) -{ - this->m_Cursor->VisibilityOff( ); - this->m_Text->VisibilityOff( ); -} - -// ------------------------------------------------------------------------- -cpExtensions::Visualization::ImageViewerActors:: -ImageViewerActors( ) - : Superclass( ) -{ -} - -// ------------------------------------------------------------------------- -cpExtensions::Visualization::ImageViewerActors:: -~ImageViewerActors( ) -{ -} - -// ------------------------------------------------------------------------- -void cpExtensions::Visualization::ImageViewerActors:: -_CorrectPosition( double* pos, int* ijk ) -{ - auto image = this->GetImage( ); - if( image == NULL ) - return; - - // Approximate image index - double pcoords[ 3 ]; - image->ComputeStructuredCoordinates( pos, ijk, pcoords ); - - // Manually correct index - int ext[ 6 ]; - image->GetExtent( ext ); - for( int i = 0; i < 3; ++i ) - { - if( ijk[ i ] < ext[ i << 1 ] ) - ijk[ i ] = ext[ i << 1 ]; - if( ext[ ( i << 1 ) + 1 ] < ijk[ i ] ) - ijk[ i ] = ext[ ( i << 1 ) + 1 ]; - - } // rof - - // Get real coordinates - int o = this->GetOrientation( ); - ijk[ o ] = this->GetSliceNumber( ); - image->GetPoint( image->ComputePointId( ijk ), pos ); -} - -// ------------------------------------------------------------------------- -void cpExtensions::Visualization::ImageViewerActors:: -_ShowText( double* pos ) -{ - auto image = this->GetImage( ); - if( image == NULL ) - return; - - int ijk[ 3 ]; - this->_CorrectPosition( pos, ijk ); - int o = this->GetOrientation( ); - - std::stringstream buffer; - buffer << "Axis: " << char( 'X' + char( o ) ) << std::endl; - int nScl = image->GetNumberOfScalarComponents( ); - buffer - << "Pixel: [" << ijk[ 0 ] - << "," << ijk[ 1 ] - << "," << ijk[ 2 ] << "]=(" - << image->GetScalarComponentAsFloat( ijk[ 0 ], ijk[ 1 ], ijk[ 2 ], 0 ); - for( int n = 1; n < nScl; ++n ) - buffer - << " : " - << image->GetScalarComponentAsFloat( ijk[ 0 ], ijk[ 1 ], ijk[ 2 ], n ); - buffer << ")"; - cpExtensions_SPRINTF( this->m_TextBuffer, 1024, buffer.str( ).c_str( ) ); - this->m_Text->SetInput( this->m_TextBuffer ); - this->m_Text->VisibilityOn( ); - this->m_Text->Modified( ); -} - -// eof - $RCSfile$