--- /dev/null
+#include <cpExtensions/Config.h>
+
+#ifdef cpExtensions_QT4
+
+#include <cpExtensions/QT/SimpleMPRWidget.h>
+#include <cpExtensions/QT/ImageWidget.h>
+#include <cpPlugins/Interface/Workspace.h>
+
+#include <QApplication>
+#include <QWidget>
+#include <QMainWindow>
+#include <QHBoxLayout>
+
+#include <vtkImageData.h>
+
+
+#include <vtkImageTracerWidget.h>
+#include <vtkSmartPointer.h>
+#include <vtkGlyphSource2D.h>
+#include <vtkProp.h>
+
+
+#endif // cpExtensions_QT4
+
+//----------------------------------------------------------------------------
+int main( int argc, char* argv[] )
+{
+#ifdef cpExtensions_QT4
+
+ // Manage inputs
+ if( argc < 2 )
+ {
+ std::cerr << "Usage: " << argv[ 0 ] << " image_file(s)" << std::endl;
+ return( 1 );
+
+ } // fi
+
+ // Create interface
+ cpPlugins::Interface::Plugins::Pointer interface =
+ cpPlugins::Interface::Plugins::New( );
+ try
+ {
+ interface->LoadEnvironments( );
+ interface->GuessPlugins( );
+ }
+ catch( std::exception& err )
+ {
+ std::cerr << "Error caught: " << err.what( ) << std::endl;
+ return( 1 );
+
+ } // yrt
+
+ // Create workspace
+ typedef cpPlugins::Interface::Workspace _TWorkspace;
+ _TWorkspace::Pointer ws = _TWorkspace::New( );
+ ws->PrintExecutionOn( );
+
+ // Configure reader
+ auto reader = ws->CreateFilter( "IO", "ImageReader", "reader" );
+ auto params = reader->GetParameters( );
+ for( int i = 1; i < argc; ++i )
+ params->AddToOpenFileNameList( "FileNames", argv[ i ] );
+
+ // Execute reader
+ try
+ {
+ reader->Update( );
+ }
+ catch( std::exception& err )
+ {
+ std::cerr << "Error caugth: " << err.what( ) << std::endl;
+ return( 1 );
+
+ } // yrt
+
+ vtkSmartPointer< vtkImageTracerWidget > itw;
+
+ // Configure viewer
+ auto image = reader->GetOutputData< vtkImageData >( "Output" );
+ auto dim = image->GetDataDimension( );
+ switch( dim )
+ {
+ case 2: case 3:
+ {
+ // Qt initialization
+ QApplication app( argc, argv );
+ QMainWindow wnd;
+ wnd.setGeometry( 0, 0, 1024, 768 );
+
+ // Create main widget
+ QWidget* wdg = NULL;
+ if( dim == 2 )
+ {
+ auto view = new cpExtensions::QT::ImageWidget( &wnd );
+ view->SetImage( image, 2, "image" );
+ view->SetQuadrant( 2 );
+ view->SetImageOpacity( 0.5 );
+ wdg = view;
+
+ itw = vtkSmartPointer< vtkImageTracerWidget >::New( );
+ itw->SetCaptureRadius(1.5);
+ itw->GetGlyphSource()->SetColor(1, 0, 0);
+ itw->GetGlyphSource()->SetScale(3.0);
+ itw->GetGlyphSource()->SetRotationAngle(45.0);
+ itw->GetGlyphSource()->Modified();
+ itw->ProjectToPlaneOn();
+ itw->SetProjectionNormalToZAxes();
+ itw->SetProjectionPosition(
+ (
+ view->GetImageActor( )->GetBounds( )[ 4 ] +
+ view->GetImageActor( )->GetBounds( )[ 5 ]
+ ) / double( 2 )
+ );
+ itw->SetViewProp( view->GetImageActor( ) );
+ itw->SetInputData( image );
+ itw->SetInteractor( view->GetInteractor( ) );
+ itw->PlaceWidget( );
+ itw->SnapToImageOn( );
+ itw->AutoCloseOn( );
+
+ /* TODO
+ vtkSmartPointer< vtkSplineWidget > isw =
+ vtkSmartPointer< vtkSplineWidget >::New( );
+ isw.SetCurrentRenderer(ren2)
+ isw.SetDefaultRenderer(ren2)
+ isw.SetInputConnection(extract.GetOutputPort())
+ isw.SetInteractor(iren)
+ bnds = imageActor2.GetBounds()
+ isw.PlaceWidget(bnds[0], bnds[1], bnds[2], bnds[3], bnds[4], bnds[5])
+ isw.ProjectToPlaneOn()
+ isw.SetProjectionNormalToXAxes()
+ isw.SetProjectionPosition(pos)
+ */
+
+ itw->On( );
+ }
+ else
+ {
+ auto view = new cpExtensions::QT::SimpleMPRWidget( &wnd );
+ view->SetImage( image, "image" );
+ wdg = view;
+
+ } // fi
+
+ // Start application and show data
+ wnd.setCentralWidget( wdg );
+ wnd.show( );
+ return( app.exec( ) );
+ }
+ break;
+ default:
+ {
+ std::cerr << "Unmanaged dimension." << std::endl;
+ return( 1 );
+ }
+ break;
+
+ } // hctiws
+#else // cpExtensions_QT4
+ return( 0 );
+#endif // cpExtensions_QT4
+}
+
+// eof - $RCSfile$
#ifdef cpExtensions_QT4
#include <cpExtensions/QT/SimpleMPRWidget.h>
+#include <cpExtensions/QT/ImageWidget.h>
#include <cpPlugins/Interface/Workspace.h>
#include <QApplication>
int main( int argc, char* argv[] )
{
#ifdef cpExtensions_QT4
+ typedef cpPlugins::Interface::Plugins _TPlugins;
+ typedef cpPlugins::Interface::Workspace _TWorkspace;
// Manage inputs
if( argc < 2 )
} // fi
// Create interface
- cpPlugins::Interface::Plugins::Pointer interface =
- cpPlugins::Interface::Plugins::New( );
+ _TPlugins::Pointer plugins = _TPlugins::New( );
try
{
- interface->LoadEnvironments( );
- interface->GuessPlugins( );
+ plugins->LoadEnvironments( );
+ plugins->GuessPlugins( );
}
catch( std::exception& err )
{
} // yrt
// Create workspace
- typedef cpPlugins::Interface::Workspace _TWorkspace;
_TWorkspace::Pointer ws = _TWorkspace::New( );
ws->PrintExecutionOn( );
// Configure viewer
auto image = reader->GetOutputData< vtkImageData >( "Output" );
- switch( image->GetDataDimension( ) )
+ auto dim = image->GetDataDimension( );
+ switch( dim )
{
- case 2:
- {
- return( 0 );
- }
- break;
- case 3:
+ case 2: case 3:
{
// Qt initialization
QApplication app( argc, argv );
wnd.setGeometry( 0, 0, 1024, 768 );
// Create main widget
- cpExtensions::QT::SimpleMPRWidget view( &wnd );
- view.SetImage( image, "image" );
+ QWidget* wdg = NULL;
+ if( dim == 2 )
+ {
+ auto view = new cpExtensions::QT::ImageWidget( &wnd );
+ view->SetImage( image, 2, "image" );
+ wdg = view;
+ }
+ else
+ {
+ /* TODO
+ auto view = new cpExtensions::QT::SimpleMPRWidget( &wnd );
+ view->SetImage( image, "image" );
+ wdg = view;
+ */
+
+ } // fi
// Start application and show data
- wnd.setCentralWidget( &view );
+ wnd.setCentralWidget( wdg );
wnd.show( );
-
return( app.exec( ) );
}
break;
return( 1 );
}
break;
-
+
} // hctiws
#else // cpExtensions_QT4
return( 0 );
#include <cpExtensions/Interaction/ImageSliceStyle.h>
+#include <cpExtensions/Visualization/CursorActors.h>
#include <cpExtensions/Visualization/WindowLevelImageActor.h>
-#include <cpExtensions/Visualization/ImageViewerActors.h>
+#include <vtkAssemblyPath.h>
+#include <vtkImageData.h>
+#include <vtkImageSlice.h>
+#include <vtkProperty.h>
+#include <vtkPropCollection.h>
#include <vtkPropPicker.h>
+#include <vtkRenderer.h>
+/* TODO
+ #include <cpExtensions/Visualization/ImageViewerActors.h>
+*/
// -------------------------------------------------------------------------
cpExtensions::Interaction::ImageSliceStyle::
}
// -------------------------------------------------------------------------
+void cpExtensions::Interaction::ImageSliceStyle::
+OnMouseMove( )
+{
+ static bool cursor_visible = false;
+
+ int idx[ 2 ];
+ double pnt[ 3 ];
+ if( this->_PickPointOnImageActor( idx, pnt ) )
+ {
+ this->m_Cursor->SetCursor( pnt, false );
+ if( !cursor_visible )
+ {
+ this->m_Cursor->VisibilityOn( );
+ cursor_visible = true;
+
+ } // fi
+ this->Interactor->Render( );
+ }
+ else
+ {
+ if( cursor_visible )
+ {
+ this->m_Cursor->VisibilityOff( );
+ cursor_visible = false;
+ this->Interactor->Render( );
+
+ } // fi
+
+ } // fi
+
+ this->Superclass::OnMouseMove( );
+}
+
+/* TODO
cpExtensions::Visualization::ImageViewerActors*
cpExtensions::Interaction::ImageSliceStyle::
GetActors( )
OnChar( )
{
}
+*/
// -------------------------------------------------------------------------
cpExtensions::Interaction::ImageSliceStyle::
ImageSliceStyle( )
: Superclass( )
{
+ this->SetInteractionModeToImage2D( );
+ this->m_PropPicker = vtkSmartPointer< vtkPropPicker >::New( );
+ this->m_PropPicker->PickFromListOn( );
+
+ this->m_Cursor = vtkSmartPointer< TCursor >::New( );
+ this->m_Cursor->VisibilityOff( );
+ this->m_Cursor->GetProperty( 0 )->SetColor( 1, 1, 0 );
+ this->m_Cursor->GetProperty( 1 )->SetColor( 1, 1, 0 );
}
// -------------------------------------------------------------------------
{
}
+// -------------------------------------------------------------------------
+vtkProp* cpExtensions::Interaction::ImageSliceStyle::
+_ImageActor( int i )
+{
+ if( !this->CurrentRenderer )
+ return( NULL );
+
+ vtkPropCollection* props = this->CurrentRenderer->GetViewProps( );
+ vtkProp* prop = 0;
+ vtkAssemblyPath* path;
+ vtkImageSlice* imageProp = NULL;
+ vtkCollectionSimpleIterator pit;
+
+ for( int k = 0; k < 2; k++ )
+ {
+ int j = 0;
+ for( props->InitTraversal( pit ); ( prop = props->GetNextProp( pit ) ); )
+ {
+ bool foundImageProp = false;
+ for( prop->InitPathTraversal( ); ( path = prop->GetNextPath( ) ); )
+ {
+ vtkProp* tryProp = path->GetLastNode( )->GetViewProp( );
+ if( ( imageProp = vtkImageSlice::SafeDownCast( tryProp ) ) != 0 )
+ {
+ if( j == i )
+ {
+ foundImageProp = true;
+ break;
+
+ } // fi
+ imageProp = 0;
+ j++;
+
+ } // fi
+
+ } // rof
+ if( foundImageProp )
+ break;
+ } // rof
+ if( i < 0 )
+ i += j;
+
+ } // rof
+ return( imageProp );
+}
+
// -------------------------------------------------------------------------
bool cpExtensions::Interaction::ImageSliceStyle::
-_PickPosition( int idx[ 2 ], double pos[ 3 ] )
+_PickPointOnImageActor( int idx[ 2 ], double pnt[ 3 ] )
{
+ // Check if data is valid
if(
this->Interactor == NULL ||
this->CurrentRenderer == NULL ||
idx[ 1 ] = this->Interactor->GetEventPosition( )[ 1 ];
this->FindPokedRenderer( double( idx[ 0 ] ), double( idx[ 1 ] ) );
+ // Check if the image has changed
+ this->Interactor->GetPicker( )->
+ Pick( idx[ 0 ], idx[ 1 ], 0.0, this->CurrentRenderer );
+ auto picker =
+ vtkAbstractPropPicker::SafeDownCast( this->Interactor->GetPicker( ) );
+ if( picker == NULL )
+ return( false );
+ TWLActor* curr_actor = dynamic_cast< TWLActor* >( picker->GetProp3D( ) );
+ if( curr_actor != this->m_WLActor.GetPointer( ) && curr_actor != NULL )
+ {
+ this->m_WLActor = curr_actor;
+ this->m_PropPicker->GetPickList( )->RemoveAllItems( );
+ this->m_PropPicker->AddPickList( curr_actor );
+
+ this->m_Cursor->SetImageBounds( curr_actor->GetImage( )->GetBounds( ) );
+ this->m_Cursor->SetImageOrientation( curr_actor->GetOrientation( ) );
+ this->m_Cursor->InitTraversal( );
+ while( vtkProp* prop = this->m_Cursor->GetNextProp( ) )
+ this->CurrentRenderer->AddViewProp( prop );
+
+ } // fi
+ if( this->m_WLActor.GetPointer( ) == NULL )
+ {
+ this->m_PropPicker->GetPickList( )->RemoveAllItems( );
+ return( false );
+
+ } // fi
+
// Pick a 3D position
int r = this->m_PropPicker->Pick(
double( idx[ 0 ] ), double( idx[ 1 ] ), double( 0 ),
);
if( r == 0 )
return( false );
- this->m_PropPicker->GetPickPosition( pos );
+ this->m_PropPicker->GetPickPosition( pnt );
return( true );
}
#ifndef __cpExtensions__Interaction__ImageSliceStyle__h__
#define __cpExtensions__Interaction__ImageSliceStyle__h__
-#include <cpExtensions/Interaction/BaseStyle.h>
+#include <cpExtensions/Config.h>
+#include <vtkInteractorStyleImage.h>
#include <vtkSmartPointer.h>
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
namespace cpExtensions
{
- namespace Visualization { class ImageViewerActors; }
-
+ namespace Visualization
+ {
+ class CursorActors;
+ class WindowLevelImageActor;
+ }
namespace Interaction
{
/**
*/
class cpExtensions_EXPORT ImageSliceStyle
- : public BaseStyle
+ : public vtkInteractorStyleImage
{
public:
typedef ImageSliceStyle Self;
+ typedef cpExtensions::Visualization::CursorActors TCursor;
+ typedef cpExtensions::Visualization::WindowLevelImageActor TWLActor;
public:
- vtkTypeMacro( ImageSliceStyle, BaseStyle );
+ vtkTypeMacro( ImageSliceStyle, vtkInteractorStyleImage );
public:
static Self* New( );
- cpExtensions::Visualization::ImageViewerActors* GetActors( );
- const cpExtensions::Visualization::ImageViewerActors* GetActors( ) const;
- void SetActors( cpExtensions::Visualization::ImageViewerActors* actors );
-
- // Events
virtual void OnMouseMove( ) cpExtensions_OVERRIDE;
- virtual void OnMouseWheelForward( ) cpExtensions_OVERRIDE;
- virtual void OnMouseWheelBackward( ) cpExtensions_OVERRIDE;
- virtual void OnChar( ) cpExtensions_OVERRIDE;
+
+ /* TODO
+ cpExtensions::Visualization::ImageViewerActors* GetActors( );
+ const cpExtensions::Visualization::ImageViewerActors* GetActors( ) const;
+ void SetActors( cpExtensions::Visualization::ImageViewerActors* actors );
+
+ // Events
+ virtual void OnMouseMove( ) cpExtensions_OVERRIDE;
+ virtual void OnMouseWheelForward( ) cpExtensions_OVERRIDE;
+ virtual void OnMouseWheelBackward( ) cpExtensions_OVERRIDE;
+ virtual void OnChar( ) cpExtensions_OVERRIDE;
+ */
protected:
ImageSliceStyle( );
virtual ~ImageSliceStyle( );
- virtual bool _PickPosition( int idx[ 2 ], double pos[ 3 ] ) cpExtensions_OVERRIDE;
+ virtual vtkProp* _ImageActor( int i );
+ virtual bool _PickPointOnImageActor( int idx[ 2 ], double pnt[ 3 ] );
private:
// Purposely not implemented
Self& operator=( const Self& );
protected:
- vtkSmartPointer< cpExtensions::Visualization::ImageViewerActors > m_Actors;
vtkSmartPointer< vtkPropPicker > m_PropPicker;
+ vtkSmartPointer< TWLActor > m_WLActor;
+ vtkSmartPointer< TCursor > m_Cursor;
+ /* TODO
+ vtkSmartPointer< cpExtensions::Visualization::ImageViewerActors > m_Actors;
+ */
};
} // ecapseman
#ifdef cpExtensions_QT4
-#include <cpExtensions/Visualization/ImageViewerActors.h>
-#include <cpExtensions/Visualization/LUTImageActor.h>
-#include <cpExtensions/Visualization/WindowLevelImageActor.h>
#include <cpExtensions/Interaction/ImageSliceStyle.h>
-#include <vtkCamera.h>
-#include <vtkImageData.h>
-#include <vtkImageProperty.h>
+#include <cpExtensions/Visualization/ImageOutlineActor.h>
+#include <cpExtensions/Visualization/WindowLevelImageActor.h>
+
#include <vtkRenderer.h>
+/* TODO
+ #include <cpExtensions/Visualization/ImageViewerActors.h>
+ #include <cpExtensions/Visualization/LUTImageActor.h>
+ #include <vtkCamera.h>
+ #include <vtkImageData.h>
+ #include <vtkImageProperty.h>
+*/
+
// -------------------------------------------------------------------------
cpExtensions::QT::ImageWidget::
ImageWidget( QWidget* parent, Qt::WindowFlags f )
: Superclass( parent, f ),
m_ImageName( "" )
{
- this->m_ImageSliceStyle =
- vtkSmartPointer< cpExtensions::Interaction::ImageSliceStyle >::New( );
- this->m_ImageSliceStyle->SetCurrentRenderer( this->m_Renderer );
- this->SetStyle( this->m_ImageSliceStyle );
+ this->m_Style = vtkSmartPointer< TStyle >::New( );
+ this->m_Style->SetCurrentRenderer( this->m_Renderer );
+ this->SetStyle( this->m_Style );
}
// -------------------------------------------------------------------------
{
}
+// -------------------------------------------------------------------------
+void cpExtensions::QT::ImageWidget::
+Clear( )
+{
+ this->RemoveViewProps( );
+ this->m_ImageName = "";
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::ImageWidget::
+SetImage( vtkImageData* image, int orientation, const std::string& name )
+{
+ if( name == "" )
+ return;
+ if( this->m_ImageName != "" )
+ this->Clear( );
+ this->m_ImageName = name;
+
+ this->m_WLActor = vtkSmartPointer< TWLActor >::New( );
+ this->m_WLActor->SetImage( image );
+ this->m_WLActor->SetOrientation( orientation );
+
+ this->m_OLActor = vtkSmartPointer< TOLActor >::New( );
+ this->m_OLActor->SetBounds(
+ orientation,
+ this->m_WLActor->GetBounds( )[ orientation ],
+ this->m_WLActor->GetBounds( )
+ );
+
+ this->AddViewProp( this->m_WLActor, this->m_ImageName );
+ this->AddAuxViewProp( this->m_OLActor, this->m_ImageName );
+ this->ResetCamera( );
+}
+
+
+/* TODO
// -------------------------------------------------------------------------
vtkInteractorStyle* cpExtensions::QT::ImageWidget::
GetInteractorStyle( )
if( image == NULL )
{
- /* TODO
if( this->m_ImageName == "" )
this->SetImage( data, name );
{
} // fi
- */
return;
} // fi
} // fi
}
+// -------------------------------------------------------------------------
+vtkProp* cpExtensions::QT::ImageWidget::
+GetImageActor( )
+{
+ return( this->m_ImageViewerActors->GetWindowLevelImageActor( ) );
+}
+
+// -------------------------------------------------------------------------
+const vtkProp* cpExtensions::QT::ImageWidget::
+GetImageActor( ) const
+{
+ return( this->m_ImageViewerActors->GetWindowLevelImageActor( ) );
+}
+*/
+
#endif // cpExtensions_QT4
// eof - $RCSfile$
#ifdef cpExtensions_QT4
-class vtkDataSet;
+// TODO: class vtkDataSet;
namespace cpExtensions
{
namespace Visualization
{
- class ImageSliceActors;
- class ImageViewerActors;
+ class ImageOutlineActor;
+ class WindowLevelImageActor;
+ /* TODO
+ class ImageSliceActors;
+ class ImageViewerActors;
+ */
}
namespace Interaction { class ImageSliceStyle; }
typedef ImageWidget Self;
typedef RendererWidget Superclass;
+ typedef cpExtensions::Visualization::ImageOutlineActor TOLActor;
+ typedef cpExtensions::Visualization::WindowLevelImageActor TWLActor;
+ typedef cpExtensions::Interaction::ImageSliceStyle TStyle;
+
public:
explicit ImageWidget( QWidget* parent = NULL, Qt::WindowFlags f = 0 );
virtual ~ImageWidget( );
- vtkInteractorStyle* GetInteractorStyle( );
- const vtkInteractorStyle* GetInteractorStyle( ) const;
-
+ void Clear( );
void SetImage(
vtkImageData* image, int orientation, const std::string& name
);
- void Add( vtkDataSet* data, const std::string& name );
- // TODO: std::vector< vtkProp* > GetActors( const std::string& name ) const;
- int GetOrientation( ) const;
- void SetSliceNumber( int slice );
+ /* TODO
+ void SetImage(
+ vtkImageData* image, int orientation, const std::string& name
+ );
+ void Add( vtkDataSet* data, const std::string& name );
+
+ // TODO: std::vector< vtkProp* > GetActors( const std::string& name ) const;
+ int GetOrientation( ) const;
+ void SetSliceNumber( int slice );
+
+ virtual void ResetCamera( ) cpExtensions_OVERRIDE;
- virtual void ResetCamera( ) cpExtensions_OVERRIDE;
+ void GetScalarRange( double r[ 2 ] ) const;
+ void GetWindowLevel( double wl[ 2 ] ) const;
+ double GetImageOpacity( ) const;
+ unsigned char GetImageInterpolation( ) const;
- void GetScalarRange( double r[ 2 ] ) const;
- void GetWindowLevel( double wl[ 2 ] ) const;
- double GetImageOpacity( ) const;
- unsigned char GetImageInterpolation( ) const;
+ void SetScalarRange( double r[ 2 ] );
+ void SetWindowLevel( double wl[ 2 ] );
+ void SetImageOpacity( double o );
+ void SetImageInterpolation( unsigned char i );
- void SetScalarRange( double r[ 2 ] );
- void SetWindowLevel( double wl[ 2 ] );
- void SetImageOpacity( double o );
- void SetImageInterpolation( unsigned char i );
+ vtkProp* GetImageActor( );
+ const vtkProp* GetImageActor( ) const;
+ */
protected:
- vtkSmartPointer< cpExtensions::Visualization::ImageViewerActors >
- m_ImageViewerActors;
- vtkSmartPointer< cpExtensions::Interaction::ImageSliceStyle >
- m_ImageSliceStyle;
std::string m_ImageName;
+
+ vtkSmartPointer< TWLActor > m_WLActor;
+ vtkSmartPointer< TOLActor > m_OLActor;
+
+ vtkSmartPointer< TStyle > m_Style;
+
+ /* TODO
+ protected:
+ vtkSmartPointer< cpExtensions::Visualization::ImageViewerActors >
+ m_ImageViewerActors;
+ vtkSmartPointer< cpExtensions::Interaction::ImageSliceStyle >
+ m_ImageSliceStyle;
+ std::string m_ImageName;
+ */
};
} // ecapseman
void cpExtensions::QT::MPRInteractionCommand::
AddWidget( QWidget* w )
{
- typedef cpExtensions::QT::ImageWidget _TImageWidget;
- typedef cpExtensions::QT::MPR3DWidget _TMPR3DWidget;
+ /*
+ typedef cpExtensions::QT::ImageWidget _TImageWidget;
+ typedef cpExtensions::QT::MPR3DWidget _TMPR3DWidget;
- auto img = dynamic_cast< _TImageWidget* >( w );
- auto ren = dynamic_cast< _TMPR3DWidget* >( w );
- if( img != NULL )
+ auto img = dynamic_cast< _TImageWidget* >( w );
+ auto ren = dynamic_cast< _TMPR3DWidget* >( w );
+ if( img != NULL )
this->m_ImageWidgets.insert( img );
- else if( ren != NULL )
+ else if( ren != NULL )
this->m_MPR3DWidgets.insert( ren );
+ */
}
// -------------------------------------------------------------------------
void cpExtensions::QT::MPRInteractionCommand::
Execute( vtkObject* caller, unsigned long evId, void* data )
{
+ /*
typedef cpExtensions::Interaction::ImageSliceStyle _TStyle;
static const unsigned long _SuperCursor = vtkCommand::UserEvent + 1;
( *r )->SetSliceNumber( ori, slice );
} // fi
+ */
}
// -------------------------------------------------------------------------
#ifdef cpExtensions_QT4
#include <vtkAxesActor.h>
+#include <vtkCamera.h>
#include <vtkInteractorStyle.h>
#include <vtkOrientationMarkerWidget.h>
#include <vtkRenderer.h>
vtkInteractorStyle* cpExtensions::QT::RendererWidget::
GetStyle( )
{
- return(
- dynamic_cast< vtkInteractorStyle* >(
- this->GetInteractor( )->GetInteractorStyle( )
- )
- );
+ auto iren = this->GetInteractor( );
+ if( iren != NULL )
+ return(
+ dynamic_cast< vtkInteractorStyle* >( iren->GetInteractorStyle( ) )
+ );
+ else
+ return( NULL );
}
// -------------------------------------------------------------------------
// Ugly, but necessary :-(
Self* self = const_cast< Self* >( this );
if( self != NULL )
- return(
- dynamic_cast< const vtkInteractorStyle* >(
- self->GetInteractor( )->GetInteractorStyle( )
- )
- );
+ {
+ auto iren = self->GetInteractor( );
+ if( iren != NULL )
+ return(
+ dynamic_cast< const vtkInteractorStyle* >(
+ iren->GetInteractorStyle( )
+ )
+ );
+ else
+ return( NULL );
+ }
else
return( NULL );
}
{
if( prop != NULL )
{
- if( this->m_ViewProps.find( name ) == this->m_ViewProps.end( ) )
- {
- vtkSmartPointer< vtkPropCollection > coll =
- vtkSmartPointer< vtkPropCollection >::New( );
- coll->AddItem( prop );
- this->m_ViewProps[ name ] = coll;
- this->m_Renderer->AddViewProp( prop );
-
- } // fi
+ auto i = this->m_ViewProps.find( name );
+ if( i == this->m_ViewProps.end( ) )
+ i =
+ this->m_ViewProps.insert(
+ TPropCollection::value_type( name, TProps( ) )
+ ).first;
+ i->second.insert( prop );
+ this->m_Renderer->AddViewProp( prop );
} // fi
}
{
if( props != NULL )
{
- if( this->m_ViewProps.find( name ) == this->m_ViewProps.end( ) )
+ auto i = this->m_ViewProps.find( name );
+ if( i == this->m_ViewProps.end( ) )
+ i =
+ this->m_ViewProps.insert(
+ TPropCollection::value_type( name, TProps( ) )
+ ).first;
+ props->InitTraversal( );
+ while( vtkProp* prop = props->GetNextProp( ) )
{
- this->m_ViewProps[ name ] = props;
- props->InitTraversal( );
- while( vtkProp* p = props->GetNextProp( ) )
- this->m_Renderer->AddViewProp( p );
+ i->second.insert( prop );
+ this->m_Renderer->AddViewProp( prop );
- } // fi
+ } // elihw
} // fi
}
{
if( prop != NULL )
{
- if( this->m_ViewProps.find( name ) != this->m_ViewProps.end( ) )
- {
- auto a = this->m_AuxViewProps.find( name );
- vtkSmartPointer< vtkPropCollection > coll;
- if( a == this->m_AuxViewProps.end( ) )
- {
- coll = vtkSmartPointer< vtkPropCollection >::New( );
- this->m_AuxViewProps[ name ] = coll;
- }
- else
- coll = a->second;
- coll->AddItem( prop );
- this->m_Renderer->AddViewProp( prop );
-
- } // fi
+ auto i = this->m_AuxViewProps.find( name );
+ if( i == this->m_AuxViewProps.end( ) )
+ i =
+ this->m_AuxViewProps.insert(
+ TPropCollection::value_type( name, TProps( ) )
+ ).first;
+ i->second.insert( prop );
+ this->m_Renderer->AddViewProp( prop );
} // fi
}
void cpExtensions::QT::RendererWidget::
AddAuxViewProps( vtkPropCollection* props, const std::string& name )
{
- props->InitTraversal( );
- while( auto p = props->GetNextProp( ) )
- this->AddAuxViewProp( p, name );
+ if( props != NULL )
+ {
+ auto i = this->m_AuxViewProps.find( name );
+ if( i == this->m_AuxViewProps.end( ) )
+ i =
+ this->m_AuxViewProps.insert(
+ TPropCollection::value_type( name, TProps( ) )
+ ).first;
+ props->InitTraversal( );
+ while( vtkProp* prop = props->GetNextProp( ) )
+ {
+ i->second.insert( prop );
+ this->m_Renderer->AddViewProp( prop );
+
+ } // elhiw
+
+ } // fi
}
// -------------------------------------------------------------------------
-vtkPropCollection* cpExtensions::QT::RendererWidget::
+cpExtensions::QT::RendererWidget::
+TProps& cpExtensions::QT::RendererWidget::
GetViewProps( const std::string& name )
{
+ static TProps zero;
auto i = this->m_ViewProps.find( name );
- if( i != this->m_ViewProps.end( ) )
- return( i->second );
+ if( i == this->m_ViewProps.end( ) )
+ {
+ zero.clear( );
+ return( zero );
+ }
else
- return( NULL );
+ return( i->second );
}
// -------------------------------------------------------------------------
-const vtkPropCollection* cpExtensions::QT::RendererWidget::
+const cpExtensions::QT::RendererWidget::
+TProps& cpExtensions::QT::RendererWidget::
GetViewProps( const std::string& name ) const
{
+ static const TProps zero;
auto i = this->m_ViewProps.find( name );
- if( i != this->m_ViewProps.end( ) )
- return( i->second );
+ if( i == this->m_ViewProps.end( ) )
+ return( zero );
else
- return( NULL );
+ return( i->second );
}
// -------------------------------------------------------------------------
-vtkPropCollection* cpExtensions::QT::RendererWidget::
+cpExtensions::QT::RendererWidget::
+TProps& cpExtensions::QT::RendererWidget::
GetAuxViewProps( const std::string& name )
{
+ static TProps zero;
auto i = this->m_AuxViewProps.find( name );
- if( i != this->m_AuxViewProps.end( ) )
- return( i->second );
+ if( i == this->m_AuxViewProps.end( ) )
+ {
+ zero.clear( );
+ return( zero );
+ }
else
- return( NULL );
+ return( i->second );
}
// -------------------------------------------------------------------------
-const vtkPropCollection* cpExtensions::QT::RendererWidget::
+const cpExtensions::QT::RendererWidget::
+TProps& cpExtensions::QT::RendererWidget::
GetAuxViewProps( const std::string& name ) const
{
+ static const TProps zero;
auto i = this->m_AuxViewProps.find( name );
- if( i != this->m_AuxViewProps.end( ) )
- return( i->second );
+ if( i == this->m_AuxViewProps.end( ) )
+ return( zero );
else
- return( NULL );
+ return( i->second );
}
// -------------------------------------------------------------------------
auto i = this->m_ViewProps.find( name );
if( i != this->m_ViewProps.end( ) )
{
- i->second->InitTraversal( );
- while( auto p = i->second->GetNextProp( ) )
- this->m_Renderer->RemoveViewProp( p );
+ for( auto p = i->second.begin( ); p != i->second.end( ); ++p )
+ this->m_Renderer->RemoveViewProp( *p );
this->m_ViewProps.erase( i );
- i = this->m_AuxViewProps.find( name );
- if( i != this->m_AuxViewProps.end( ) )
- {
- i->second->InitTraversal( );
- while( auto p = i->second->GetNextProp( ) )
- this->m_Renderer->RemoveViewProp( p );
- this->m_AuxViewProps.erase( i );
+ } // fi
- } // fi
+ i = this->m_AuxViewProps.find( name );
+ if( i != this->m_AuxViewProps.end( ) )
+ {
+ for( auto p = i->second.begin( ); p != i->second.end( ); ++p )
+ this->m_Renderer->RemoveViewProp( *p );
+ this->m_AuxViewProps.erase( i );
} // fi
}
{
auto i = this->m_ViewProps.find( name );
if( i != this->m_ViewProps.end( ) )
- {
- i->second->InitTraversal( );
- while( auto p = i->second->GetNextProp( ) )
- p->VisibilityOff( );
-
- i = this->m_AuxViewProps.find( name );
- if( i != this->m_AuxViewProps.end( ) )
- {
- i->second->InitTraversal( );
- while( auto p = i->second->GetNextProp( ) )
- p->VisibilityOff( );
-
- } // fi
-
- } // fi
+ for( auto p = i->second.begin( ); p != i->second.end( ); ++p )
+ ( *p )->VisibilityOff( );
+ i = this->m_AuxViewProps.find( name );
+ if( i != this->m_AuxViewProps.end( ) )
+ for( auto p = i->second.begin( ); p != i->second.end( ); ++p )
+ ( *p )->VisibilityOff( );
}
// -------------------------------------------------------------------------
{
auto i = this->m_ViewProps.find( name );
if( i != this->m_ViewProps.end( ) )
- {
- i->second->InitTraversal( );
- while( auto p = i->second->GetNextProp( ) )
- p->VisibilityOn( );
-
- i = this->m_AuxViewProps.find( name );
- if( i != this->m_AuxViewProps.end( ) )
- {
- i->second->InitTraversal( );
- while( auto p = i->second->GetNextProp( ) )
- p->VisibilityOn( );
-
- } // fi
-
- } // fi
-}
-
-
-/*
-// -------------------------------------------------------------------------
-const cpExtensions::QT::RendererWidget::
-TNamedActors& cpExtensions::QT::RendererWidget::
-GetNamedActors( ) const
-{
- return( this->m_NamedActors );
-}
-
-// -------------------------------------------------------------------------
-cpExtensions::QT::RendererWidget::
-TProps& cpExtensions::QT::RendererWidget::
-GetViewProps( const std::string& name )
-{
- static TProps empty;
- auto i = this->m_NamedActors.find( name );
- if( i == this->m_NamedActors.end( ) )
- {
- empty = NULL;
- return( empty );
- }
- else
- return( i->second );
-}
-
-// -------------------------------------------------------------------------
-const cpExtensions::QT::RendererWidget::
-TProps& cpExtensions::QT::RendererWidget::
-GetViewProps( const std::string& name ) const
-{
- static const TProps empty = NULL;
- auto i = this->m_NamedActors.find( name );
- if( i == this->m_NamedActors.end( ) )
- return( empty );
- else
- return( i->second );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::RendererWidget::
-AddViewProp( vtkProp* prop, const std::string& name )
-{
- if( this->m_NamedActors.find( name ) == this->m_NamedActors.end( ) )
- {
- TProps coll = TProps::New( );
- coll->AddItem( prop );
- this->m_NamedActors[ name ] = coll;
- this->m_Renderer->AddViewProp( prop );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::RendererWidget::
-AddViewProps( vtkPropCollection* coll, const std::string& name )
-{
- if( this->m_NamedActors.find( name ) == this->m_NamedActors.end( ) )
- {
- this->m_NamedActors[ name ] = coll;
- coll->InitTraversal( );
- while( vtkProp* prop = coll->GetNextProp( ) )
- this->m_Renderer->AddViewProp( prop );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::RendererWidget::
-RemoveViewProps( )
-{
- this->m_Renderer->RemoveAllViewProps( );
- this->m_NamedActors.clear( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::RendererWidget::
-RemoveViewProps( const std::string& name )
-{
- auto a = this->m_NamedActors.find( name );
- if( a != this->m_NamedActors.end( ) )
- {
- a->second->InitTraversal( );
- while( vtkProp* prop = a->second->GetNextProp( ) )
- this->m_Renderer->RemoveViewProp( prop );
- this->m_NamedActors.erase( a );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::RendererWidget::
-HideViewProps( const std::string& name )
-{
- auto a = this->m_NamedActors.find( name );
- if( a != this->m_NamedActors.end( ) )
- {
- a->second->InitTraversal( );
- while( vtkProp* prop = a->second->GetNextProp( ) )
- prop->VisibilityOff( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::QT::RendererWidget::
-ShowViewProps( const std::string& name )
-{
- auto a = this->m_NamedActors.find( name );
- if( a != this->m_NamedActors.end( ) )
- {
- a->second->InitTraversal( );
- while( vtkProp* prop = a->second->GetNextProp( ) )
- prop->VisibilityOn( );
-
- } // fi
+ for( auto p = i->second.begin( ); p != i->second.end( ); ++p )
+ ( *p )->VisibilityOn( );
+ i = this->m_AuxViewProps.find( name );
+ if( i != this->m_AuxViewProps.end( ) )
+ for( auto p = i->second.begin( ); p != i->second.end( ); ++p )
+ ( *p )->VisibilityOn( );
}
-*/
// -------------------------------------------------------------------------
void cpExtensions::QT::RendererWidget::
ResetCamera( )
{
- /* TODO
- double bounds[ 6 ] = { 0, 1, 0, 1, 0, 1 };
- double b[ 6 ];
- bool start = true;
- for(
- auto props = this->m_ViewProps.begin( );
- props != this->m_ViewProps.end( );
- ++props
- )
- {
- props->second->InitTraversal( );
- while(
- auto prop = dynamic_cast< vtkProp3D* >( props->second->GetNextProp( ) )
- )
- {
- if( !start )
- {
- prop->GetBounds( b );
- bounds[ 0 ] = ( b[ 0 ] < bounds[ 0 ] )? b[ 0 ]: bounds[ 0 ];
- bounds[ 1 ] = ( bounds[ 1 ] < b[ 1 ] )? b[ 1 ]: bounds[ 1 ];
- bounds[ 2 ] = ( b[ 2 ] < bounds[ 2 ] )? b[ 2 ]: bounds[ 2 ];
- bounds[ 3 ] = ( bounds[ 3 ] < b[ 3 ] )? b[ 3 ]: bounds[ 3 ];
- bounds[ 4 ] = ( b[ 4 ] < bounds[ 4 ] )? b[ 4 ]: bounds[ 4 ];
- bounds[ 5 ] = ( bounds[ 5 ] < b[ 5 ] )? b[ 5 ]: bounds[ 5 ];
- }
- else
- prop->GetBounds( bounds );
-
- } // elihw
-
- } // rof
- */
this->m_Renderer->ResetCamera( );
}
#include <vtkSmartPointer.h>
#include <map>
#include <set>
+#include <string>
// -------------------------------------------------------------------------
class vtkCamera;
class vtkOrientationMarkerWidget;
class vtkProp;
class vtkPropCollection;
-class vtkRenderer;
// -------------------------------------------------------------------------
namespace cpExtensions
typedef RendererWidget Self;
typedef cpExtensions_QVTKWidget Superclass;
- typedef
- std::map< std::string, vtkSmartPointer< vtkPropCollection > >
- TProps;
+ typedef std::set< vtkSmartPointer< vtkProp > > TProps;
+ typedef std::map< std::string, TProps > TPropCollection;
public:
- explicit RendererWidget( QWidget* parent = NULL, Qt::WindowFlags f = 0 );
+ explicit RendererWidget(
+ QWidget* parent = NULL, Qt::WindowFlags f = 0
+ );
virtual ~RendererWidget( );
int GetQuadrant( ) const;
vtkCamera* GetActiveCamera( );
const vtkCamera* GetActiveCamera( ) const;
- void AddViewProp( vtkProp* prop, const std::string& name );
- void AddViewProps( vtkPropCollection* props, const std::string& name );
- void AddAuxViewProp( vtkProp* prop, const std::string& name );
- void AddAuxViewProps( vtkPropCollection* props, const std::string& name );
+ void AddViewProp( vtkProp* prop, const std::string& name = "" );
+ void AddViewProps(
+ vtkPropCollection* props, const std::string& name = ""
+ );
+ void AddAuxViewProp( vtkProp* prop, const std::string& name = "" );
+ void AddAuxViewProps(
+ vtkPropCollection* props, const std::string& name = ""
+ );
- vtkPropCollection* GetViewProps( const std::string& name );
- const vtkPropCollection* GetViewProps( const std::string& name ) const;
- vtkPropCollection* GetAuxViewProps( const std::string& name );
- const vtkPropCollection* GetAuxViewProps( const std::string& name ) const;
+ TProps& GetViewProps( const std::string& name );
+ const TProps& GetViewProps( const std::string& name ) const;
+ TProps& GetAuxViewProps( const std::string& name );
+ const TProps& GetAuxViewProps( const std::string& name ) const;
void RemoveViewProps( const std::string& name );
void RemoveViewProps( );
virtual void Render( );
protected:
- vtkSmartPointer< vtkRenderer > m_Renderer;
+ vtkSmartPointer< vtkRenderer > m_Renderer;
vtkSmartPointer< vtkOrientationMarkerWidget > m_Marker;
int m_Quadrant;
- TProps m_ViewProps;
- TProps m_AuxViewProps;
+ TPropCollection m_ViewProps;
+ TPropCollection m_AuxViewProps;
};
} // ecapseman
m_UI( new Ui::SimpleMPRWidget ),
m_MainImageName( "" )
{
+/*
this->m_UI->setupUi( this );
// Prepare default configuration
this->m_UI->ConfigurationButton, SIGNAL( clicked( ) ),
this, SLOT( _ConfigurationButton( ) )
);
+*/
}
// -------------------------------------------------------------------------
Add( vtkDataSet* data, const std::string& name )
{
bool success = true;
+/*
auto image = dynamic_cast< vtkImageData* >( data );
auto pdata = dynamic_cast< vtkPolyData* >( data );
this->m_3DView->Add( pdata, name );
else
success = false;
+*/
return( success );
}
TProps cpExtensions::QT::SimpleMPRWidget::
GetViewProps( const std::string& name ) const
{
+/*
auto x = this->m_XImage->GetViewProps( name );
auto y = this->m_YImage->GetViewProps( name );
auto z = this->m_ZImage->GetViewProps( name );
if( z != NULL ) props.insert( z );
if( w != NULL ) props.insert( w );
return( props );
+*/
}
// -------------------------------------------------------------------------
void cpExtensions::QT::SimpleMPRWidget::
GetScalarRange( double r[ 2 ] ) const
{
- this->m_XImage->GetScalarRange( r );
+// this->m_XImage->GetScalarRange( r );
}
// -------------------------------------------------------------------------
void cpExtensions::QT::SimpleMPRWidget::
GetWindowLevel( double wl[ 2 ] ) const
{
- this->m_XImage->GetWindowLevel( wl );
+// this->m_XImage->GetWindowLevel( wl );
}
// -------------------------------------------------------------------------
double cpExtensions::QT::SimpleMPRWidget::
GetImageOpacity( ) const
{
- return( this->m_XImage->GetImageOpacity( ) );
+// return( this->m_XImage->GetImageOpacity( ) );
}
// -------------------------------------------------------------------------
unsigned char cpExtensions::QT::SimpleMPRWidget::
GetImageInterpolation( ) const
{
- return( this->m_XImage->GetImageInterpolation( ) );
+// return( this->m_XImage->GetImageInterpolation( ) );
}
// -------------------------------------------------------------------------
void cpExtensions::QT::SimpleMPRWidget::
SetScalarRange( double r[ 2 ] )
{
+/*
this->m_XImage->SetScalarRange( r );
this->m_YImage->SetScalarRange( r );
this->m_ZImage->SetScalarRange( r );
this->m_3DView->SetScalarRange( r );
+*/
}
// -------------------------------------------------------------------------
void cpExtensions::QT::SimpleMPRWidget::
SetWindowLevel( double wl[ 2 ] )
{
+/*
this->m_XImage->SetWindowLevel( wl );
this->m_YImage->SetWindowLevel( wl );
this->m_ZImage->SetWindowLevel( wl );
this->m_3DView->SetWindowLevel( wl );
+*/
}
// -------------------------------------------------------------------------
void cpExtensions::QT::SimpleMPRWidget::
SetImageOpacity( double o )
{
+/*
this->m_XImage->SetImageOpacity( o );
this->m_YImage->SetImageOpacity( o );
this->m_ZImage->SetImageOpacity( o );
this->m_3DView->SetImageOpacity( o );
+*/
}
// -------------------------------------------------------------------------
void cpExtensions::QT::SimpleMPRWidget::
SetImageInterpolation( unsigned char i )
{
+ /*
this->m_XImage->SetImageInterpolation( i );
this->m_YImage->SetImageInterpolation( i );
this->m_ZImage->SetImageInterpolation( i );
this->m_3DView->SetImageInterpolation( i );
+*/
}
// -------------------------------------------------------------------------
void cpExtensions::QT::SimpleMPRWidget::
ResetCameras( )
{
+/*
this->m_XImage->ResetCamera( );
this->m_YImage->ResetCamera( );
this->m_ZImage->ResetCamera( );
this->m_3DView->ResetCamera( );
+*/
}
// -------------------------------------------------------------------------
void cpExtensions::QT::SimpleMPRWidget::
Render( )
{
+/*
this->m_XImage->Render( );
this->m_YImage->Render( );
this->m_ZImage->Render( );
this->m_3DView->Render( );
+*/
}
// -------------------------------------------------------------------------
return( this->m_Mapper->GetSliceNumber( ) );
}
-#include <vtkPropCollection.h>
-#include <typeinfo>
-
// -------------------------------------------------------------------------
void cpExtensions::Visualization::ImageActor::
SetSliceNumber( int slice )
s = this->m_Mapper->GetSliceNumberMaxValue( );
this->m_Mapper->SetSliceNumber( s );
- // Update display extent
- /* TODO
- int ext[ 6 ];
- image->GetExtent( ext );
- int o = this->m_Mapper->GetOrientation( );
- ext[ o << 1 ] = ext[ ( o << 1 ) + 1 ] = s;
- this->SetDisplayExtent( ext );
- */
-
// Propagate modifications
this->Modified( );
mySlice = slice;
public:
static Self* New( );
- virtual void Modified( ) VTK_OVERRIDE;
+ virtual void Modified( ) cpExtensions_OVERRIDE;
void SetBounds( int orientation, double step, double* bounds );
void cpExtensions::Visualization::MPR3DActors::
SetScalarRange( double r[ 2 ] )
{
- this->m_Slices[ 0 ]->
- GetWindowLevelImageActor( )->ConfigureWindowLevel( r[ 0 ], r[ 1 ] );
- this->m_Slices[ 1 ]->
- GetWindowLevelImageActor( )->ConfigureWindowLevel( r[ 0 ], r[ 1 ] );
- this->m_Slices[ 2 ]->
- GetWindowLevelImageActor( )->ConfigureWindowLevel( r[ 0 ], r[ 1 ] );
+ this->m_Slices[ 0 ]->GetWindowLevelImageActor( )->SetRange( r );
+ this->m_Slices[ 1 ]->GetWindowLevelImageActor( )->SetRange( r );
+ this->m_Slices[ 2 ]->GetWindowLevelImageActor( )->SetRange( r );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPR3DActors::
SetWindowLevel( double wl[ 2 ] )
{
- this->m_Slices[ 0 ]->
- GetWindowLevelImageActor( )->SetWindowLevel( wl[ 0 ], wl[ 1 ] );
- this->m_Slices[ 1 ]->
- GetWindowLevelImageActor( )->SetWindowLevel( wl[ 0 ], wl[ 1 ] );
- this->m_Slices[ 2 ]->
- GetWindowLevelImageActor( )->SetWindowLevel( wl[ 0 ], wl[ 1 ] );
+ this->m_Slices[ 0 ]->GetWindowLevelImageActor( )->SetWindowLevel( wl );
+ this->m_Slices[ 1 ]->GetWindowLevelImageActor( )->SetWindowLevel( wl );
+ this->m_Slices[ 2 ]->GetWindowLevelImageActor( )->SetWindowLevel( wl );
}
// -------------------------------------------------------------------------
SetImage( vtkImageData* image )
{
this->m_Mapper->SetInputData( image );
- image->GetScalarRange( this->m_Range );
- this->ResetWindowLevel( );
+ this->ResetRange( );
this->Modified( );
}
// -------------------------------------------------------------------------
double cpExtensions::Visualization::WindowLevelImageActor::
-GetLevel( )
+GetLevel( ) const
{
- return( this->GetProperty( )->GetColorLevel( ) );
+ Self* self = const_cast< Self* >( this );
+ return( self->GetProperty( )->GetColorLevel( ) );
}
// -------------------------------------------------------------------------
double cpExtensions::Visualization::WindowLevelImageActor::
-GetWindow( )
+GetWindow( ) const
+{
+ Self* self = const_cast< Self* >( this );
+ return( self->GetProperty( )->GetColorWindow( ) );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::WindowLevelImageActor::
+GetWindowLevel( double wl[ 2 ] ) const
{
- return( this->GetProperty( )->GetColorWindow( ) );
+ Self* self = const_cast< Self* >( this );
+ wl[ 0 ] = self->GetProperty( )->GetColorWindow( );
+ wl[ 1 ] = self->GetProperty( )->GetColorLevel( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::WindowLevelImageActor::
+ResetWindowLevel( )
+{
+ this->SetWindowLevel(
+ ( this->m_Range[ 1 ] - this->m_Range[ 0 ] ),
+ ( this->m_Range[ 1 ] + this->m_Range[ 0 ] ) / double( 2 )
+ );
}
// -------------------------------------------------------------------------
void cpExtensions::Visualization::WindowLevelImageActor::
SetLevel( double l )
{
- double old_l = this->GetProperty( )->GetColorLevel( );
- if( l != old_l && this->m_Range[ 0 ] <= l && l <= this->m_Range[ 1 ] )
+ double ol = this->GetProperty( )->GetColorLevel( );
+ if( l != ol && this->m_Range[ 0 ] <= l && l <= this->m_Range[ 1 ] )
{
this->GetProperty( )->SetColorLevel( l );
this->Modified( );
void cpExtensions::Visualization::WindowLevelImageActor::
SetWindow( double w )
{
- double max_w = this->m_Range[ 1 ] - this->m_Range[ 0 ];
- double old_w = this->GetProperty( )->GetColorWindow( );
- if( w != old_w && double( 0 ) <= w && w <= max_w )
+ double mw = this->m_Range[ 1 ] - this->m_Range[ 0 ];
+ double ow = this->GetProperty( )->GetColorWindow( );
+ if( w != ow && double( 0 ) <= w && w <= mw )
{
this->GetProperty( )->SetColorWindow( w );
this->Modified( );
// -------------------------------------------------------------------------
void cpExtensions::Visualization::WindowLevelImageActor::
-ResetWindowLevel( )
+SetWindowLevel( double wl[ 2 ] )
{
- this->SetWindowLevel(
- this->m_Range[ 1 ] - this->m_Range[ 0 ],
- ( this->m_Range[ 1 ] + this->m_Range[ 0 ] ) / double( 2 )
- );
+ this->SetWindow( wl[ 0 ] );
+ this->SetLevel( wl[ 1 ] );
}
// -------------------------------------------------------------------------
-void cpExtensions::Visualization::WindowLevelImageActor::
-ConfigureWindowLevel( double min, double max )
+double cpExtensions::Visualization::WindowLevelImageActor::
+GetMinimum( ) const
{
- this->m_Range[ 0 ] = ( min < max )? min: max;
- this->m_Range[ 1 ] = ( min < max )? max: min;
- this->ResetWindowLevel( );
+ return( this->m_Range[ 0 ] );
+}
+
+// -------------------------------------------------------------------------
+double cpExtensions::Visualization::WindowLevelImageActor::
+GetMaximum( ) const
+{
+ return( this->m_Range[ 0 ] );
}
// -------------------------------------------------------------------------
r[ 1 ] = this->m_Range[ 1 ];
}
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::WindowLevelImageActor::
+ResetRange( )
+{
+ this->GetImage( )->GetScalarRange( this->m_Range );
+ this->ResetWindowLevel( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::WindowLevelImageActor::
+SetMinimum( double a )
+{
+ if( this->m_Range[ 0 ] != a )
+ {
+ this->m_Range[ 0 ] = a;
+ this->ResetWindowLevel( );
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::WindowLevelImageActor::
+SetMaximum( double b )
+{
+ if( this->m_Range[ 1 ] != b )
+ {
+ this->m_Range[ 1 ] = b;
+ this->ResetWindowLevel( );
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::WindowLevelImageActor::
+SetRange( double a, double b )
+{
+ this->SetMinimum( a );
+ this->SetMaximum( b );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::WindowLevelImageActor::
+SetRange( double r[ 2 ] )
+{
+ this->SetMinimum( r[ 0 ] );
+ this->SetMaximum( r[ 1 ] );
+}
+
// -------------------------------------------------------------------------
cpExtensions::Visualization::WindowLevelImageActor::
WindowLevelImageActor( )
: Superclass( )
{
- this->ConfigureWindowLevel( 0, 0 );
+ this->m_Range[ 0 ] = this->m_Range[ 1 ] = double( 0 );
}
// -------------------------------------------------------------------------
const vtkImageData* GetImage( ) const;
void SetImage( vtkImageData* image );
- double GetLevel( );
- double GetWindow( );
+ double GetLevel( ) const;
+ double GetWindow( ) const;
+ void GetWindowLevel( double wl[ 2 ] ) const;
+ void ResetWindowLevel( );
void SetLevel( double l );
void SetWindow( double w );
void SetWindowLevel( double w, double l );
- void ResetWindowLevel( );
- void ConfigureWindowLevel( double min, double max );
+ void SetWindowLevel( double wl[ 2 ] );
+
+ double GetMinimum( ) const;
+ double GetMaximum( ) const;
void GetRange( double r[ 2 ] ) const;
+ void ResetRange( );
+ void SetMinimum( double a );
+ void SetMaximum( double b );
+ void SetRange( double a, double b );
+ void SetRange( double r[ 2 ] );
protected:
WindowLevelImageActor( );