From f2f39f66027a98bd8dac50bade5618e0136bbefa Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Wed, 7 Oct 2015 19:50:23 -0500 Subject: [PATCH] Widget integration (step 5/6): generic widget controller finished and tested on linux... Not sure if it will work on windows --- appli/examples/CMakeLists.txt | 3 +- .../examples/example_BaseInteractorStyle.cxx | 65 +++- appli/examples/example_View2DImage.cxx | 112 +++++++ .../Visualization/BaseInteractorStyle.cxx | 161 +++------- .../Visualization/BaseInteractorStyle.h | 81 ++++- .../Visualization/ImageInteractorStyle.cxx | 300 ++++++++++++++++++ .../Visualization/ImageInteractorStyle.h | 157 +++++++-- .../Visualization/ImageSliceActors.cxx | 207 ++++++++++-- .../Visualization/ImageSliceActors.h | 61 ++-- lib/cpExtensions/Visualization/MPRObjects.cxx | 40 ++- lib/cpExtensions/Visualization/MPRObjects.h | 5 +- lib/cpPlugins/Interface/BaseProcessObjects.h | 41 ++- lib/cpPlugins/Interface/DataObject.cxx | 2 - lib/cpPlugins/Interface/DataObject.h | 3 + lib/cpPlugins/Interface/Image.cxx | 2 - lib/cpPlugins/Interface/Image.h | 3 + lib/cpPlugins/Interface/Mesh.cxx | 2 - lib/cpPlugins/Interface/Mesh.h | 3 + lib/cpPlugins/Interface/Object.h | 4 +- lib/cpPlugins/Interface/ProcessObject.cxx | 4 +- lib/cpPlugins/Interface/ProcessObject.h | 3 + .../BinaryThresholdImageFilter.cxx | 2 - .../BasicFilters/BinaryThresholdImageFilter.h | 4 + lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx | 3 - lib/cpPlugins/Plugins/BasicFilters/Cutter.h | 4 + .../BasicFilters/ExtractSliceImageFilter.cxx | 2 - .../BasicFilters/ExtractSliceImageFilter.h | 4 + .../Plugins/BasicFilters/MarchingCubes.cxx | 3 - .../Plugins/BasicFilters/MarchingCubes.h | 3 + .../BasicFilters/MedianImageFilter.cxx | 2 - .../Plugins/BasicFilters/MedianImageFilter.h | 4 + .../BasicFilters/OtsuThresholdImageFilter.cxx | 2 - .../BasicFilters/OtsuThresholdImageFilter.h | 4 + .../RGBImageToOtherChannelsFilter.cxx | 2 - .../RGBImageToOtherChannelsFilter.h | 4 + .../Plugins/BasicFilters/SphereMeshSource.cxx | 3 - .../Plugins/BasicFilters/SphereMeshSource.h | 3 + lib/cpPlugins/Plugins/IO/ImageReader.cxx | 3 - lib/cpPlugins/Plugins/IO/ImageReader.h | 3 + lib/cpPlugins/Plugins/IO/ImageWriter.cxx | 2 - lib/cpPlugins/Plugins/IO/ImageWriter.h | 3 + lib/cpPlugins/Plugins/IO/MeshReader.cxx | 3 - lib/cpPlugins/Plugins/IO/MeshReader.h | 3 + lib/cpPlugins/Plugins/IO/MeshWriter.cxx | 2 - lib/cpPlugins/Plugins/IO/MeshWriter.h | 3 + 45 files changed, 1045 insertions(+), 285 deletions(-) create mode 100644 appli/examples/example_View2DImage.cxx diff --git a/appli/examples/CMakeLists.txt b/appli/examples/CMakeLists.txt index 7943460..afbe041 100644 --- a/appli/examples/CMakeLists.txt +++ b/appli/examples/CMakeLists.txt @@ -8,6 +8,7 @@ SET( example_TestParameters example_LoadPlugins example_ReadWriteImage + example_View2DImage ##example_MarchingCubes ##example_OtsuFilter ##example_RGBImageToHSVChannels @@ -35,7 +36,7 @@ SET( NOPLUGINS_EXAMPLES_PROGRAMS example_BaseInteractorStyle example_ContourWidget - example_Test_DoubleClick + ## example_Test_DoubleClick ## example_ExtractDICOMSeries ## example_ImageGaussianModelEstimator ## example_ReadQuadEdgeMeshWithoutPlugins diff --git a/appli/examples/example_BaseInteractorStyle.cxx b/appli/examples/example_BaseInteractorStyle.cxx index 8ec545a..922511a 100644 --- a/appli/examples/example_BaseInteractorStyle.cxx +++ b/appli/examples/example_BaseInteractorStyle.cxx @@ -6,6 +6,66 @@ #include #include +// ------------------------------------------------------------------------- +#define example_BaseInteractorStyle_Macro( x ) \ + virtual void On##x( ) \ + { std::cout << "On" << #x << "( )" << std::endl; } + +// ------------------------------------------------------------------------- +class example_BaseInteractorStyle + : public cpExtensions::Visualization::BaseInteractorStyle +{ +public: + typedef example_BaseInteractorStyle Self; + vtkTypeMacro( + example_BaseInteractorStyle, + cpExtensions::Visualization::BaseInteractorStyle + ); + +public: + static Self* New( ) + { return( new Self ); } + + // Possible events + example_BaseInteractorStyle_Macro( MouseMove ); + example_BaseInteractorStyle_Macro( MouseWheelForward ); + example_BaseInteractorStyle_Macro( MouseWheelBackward ); + example_BaseInteractorStyle_Macro( LeftButtonDown ); + example_BaseInteractorStyle_Macro( LeftButtonUp ); + example_BaseInteractorStyle_Macro( LeftClick ); + example_BaseInteractorStyle_Macro( LeftDoubleClick ); + example_BaseInteractorStyle_Macro( MiddleButtonDown ); + example_BaseInteractorStyle_Macro( MiddleButtonUp ); + example_BaseInteractorStyle_Macro( MiddleClick ); + example_BaseInteractorStyle_Macro( MiddleDoubleClick ); + example_BaseInteractorStyle_Macro( RightButtonDown ); + example_BaseInteractorStyle_Macro( RightButtonUp ); + example_BaseInteractorStyle_Macro( RightClick ); + example_BaseInteractorStyle_Macro( RightDoubleClick ); + example_BaseInteractorStyle_Macro( Char ); + example_BaseInteractorStyle_Macro( KeyDown ); + example_BaseInteractorStyle_Macro( KeyUp ); + example_BaseInteractorStyle_Macro( KeyPress ); + example_BaseInteractorStyle_Macro( KeyRelease ); + example_BaseInteractorStyle_Macro( Expose ); + example_BaseInteractorStyle_Macro( Configure ); + example_BaseInteractorStyle_Macro( Enter ); + example_BaseInteractorStyle_Macro( Leave ); + +protected: + example_BaseInteractorStyle( ) + : Superclass( ) + { } + virtual ~example_BaseInteractorStyle( ) + { } + +private: + // Purposely not implemented + example_BaseInteractorStyle( const Self& ); + Self& operator=( const Self& ); +}; + +// ------------------------------------------------------------------------- int main( int argc, char* argv[] ) { // Configure visualization objects @@ -19,9 +79,8 @@ int main( int argc, char* argv[] ) window->SetSize( 600, 600 ); // Set up interaction style - typedef cpExtensions::Visualization::BaseInteractorStyle TInteractorStyle; - vtkSmartPointer< TInteractorStyle > style = - vtkSmartPointer< TInteractorStyle >::New( ); + vtkSmartPointer< example_BaseInteractorStyle > style = + vtkSmartPointer< example_BaseInteractorStyle >::New( ); // Set up the interaction vtkSmartPointer< vtkRenderWindowInteractor > interactor = diff --git a/appli/examples/example_View2DImage.cxx b/appli/examples/example_View2DImage.cxx new file mode 100644 index 0000000..66eaf29 --- /dev/null +++ b/appli/examples/example_View2DImage.cxx @@ -0,0 +1,112 @@ +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include + +// ------------------------------------------------------------------------- +typedef cpPlugins::Interface::Interface TInterface; +typedef cpPlugins::Interface::ProcessObject TProcessObject; +typedef cpPlugins::Interface::DataObject TDataObject; +typedef cpPlugins::Interface::Image TImage; +typedef cpPlugins::Interface::Parameters TParameters; +typedef TInterface::TClasses TClasses; + +typedef cpExtensions::Visualization::ImageSliceActors TSliceActors; + +// ------------------------------------------------------------------------- +int main( int argc, char* argv[] ) +{ + if( argc < 3 ) + { + std::cerr + << "Usage: " << argv[ 0 ] + << " plugins_file input_image" + << std::endl; + return( 1 ); + + } // fi + + // Create interface + TInterface plugins; + if( !plugins.Load( argv[ 1 ] ) ) + { + std::cerr << "Failed to load plugins." << std::endl; + return( 1 ); + + } // fi + + // Create objects + TProcessObject::Pointer reader; + reader = plugins.CreateProcessObject( "cpPlugins::IO::ImageReader" ); + if( reader.IsNull( ) ) + { + std::cerr + << "No suitable reader found in plugins." << std::endl + << "Reader: " << reader.GetPointer( ) << std::endl + << std::endl; + return( 1 ); + + } // fi + + // Configure reader + TParameters reader_params = reader->GetDefaultParameters( ); + for( int i = 2; i < argc; ++i ) + reader_params.AddValueToStringList( "FileNames", argv[ i ] ); + reader->SetParameters( reader_params ); + + // Execute pipeline + std::string err = reader->Update( ); + if( err != "" ) + { + std::cerr << "ERROR: " << err << std::endl; + return( 1 ); + + } // fi + TImage* image = reader->GetOutput< TImage >( 0 ); + + // Configure visualization objects + vtkSmartPointer< vtkRenderer > renderer = + vtkSmartPointer< vtkRenderer >::New( ); + renderer->SetBackground( 0.1, 0.3, 0.5 ); + + vtkSmartPointer< vtkRenderWindow > window = + vtkSmartPointer< vtkRenderWindow >::New( ); + window->AddRenderer( renderer ); + window->SetSize( 600, 600 ); + + // Set up interaction style + /* + vtkSmartPointer< example_BaseInteractorStyle > style = + vtkSmartPointer< example_BaseInteractorStyle >::New( ); + */ + + // Set up the interaction + vtkSmartPointer< vtkRenderWindowInteractor > interactor = + vtkSmartPointer< vtkRenderWindowInteractor >::New( ); + // interactor->SetInteractorStyle( style ); + window->SetInteractor( interactor ); + + // Create slice actors + vtkSmartPointer< TSliceActors > image_actors = + vtkSmartPointer< TSliceActors >::New( ); + image_actors->AddInputData( image->GetVTK< vtkImageData >( ) ); + image_actors->PushActorsInto( renderer ); + interactor->SetInteractorStyle( image_actors->GetStyle( ) ); + + // Begin interaction + window->Render( ); + interactor->Start( ); + + return( 0 ); +} + +// eof - $RCSfile$ diff --git a/lib/cpExtensions/Visualization/BaseInteractorStyle.cxx b/lib/cpExtensions/Visualization/BaseInteractorStyle.cxx index 8eb3fee..ba89696 100644 --- a/lib/cpExtensions/Visualization/BaseInteractorStyle.cxx +++ b/lib/cpExtensions/Visualization/BaseInteractorStyle.cxx @@ -1,21 +1,10 @@ #include -/* ========================================================================= - * Double click algorithm taken from: - * http://www.autohotkey.com/board/topic/56493-easiest-way-to-detect-double-clicks/ - * ========================================================================= -*/ - -/* - Compile ITK and VTK with: cmake -DCMAKE_CXX_FLAGS="-std=c++11" /dir/to/source -*/ - -#include #include // ------------------------------------------------------------------------- -const long cpExtensions::Visualization::BaseInteractorStyle:: -MAX_DOUBLE_CLICK = 200; +const long cpExtensions::Visualization::BaseInteractorStyle::MouseButtonEvent:: +MAX_DOUBLE_CLICK = 200; // ms // ------------------------------------------------------------------------- cpExtensions::Visualization::BaseInteractorStyle:: @@ -30,6 +19,8 @@ void cpExtensions::Visualization::BaseInteractorStyle:: DelegateTDxEvent( unsigned long event, void* calldata ) { // TODO + std::cerr << "No TDx support at this time!" << std::endl; + std::exit( 1 ); } // ------------------------------------------------------------------------- @@ -37,10 +28,11 @@ cpExtensions::Visualization::BaseInteractorStyle:: BaseInteractorStyle( ) : Superclass( ) { - this->LastButton = Self::ButtonID_None; - this->LastButtonUp = 0; - this->LastButtonHeld = 0; - this->LastButtonDown = -1; + this->LeftButtonEvent.Reset( ); + this->MiddleButtonEvent.Reset( ); + this->RightButtonEvent.Reset( ); + this->ActiveButton = Self::ButtonID_None; + this->EventCallbackCommand->SetCallback( Self::_ProcessEvents ); } @@ -59,7 +51,7 @@ _ProcessEvents( void* calldata ) { - // Get active style + // Get active style and interactor Self* s = reinterpret_cast< Self* >( clientdata ); if( s == NULL ) return; @@ -69,163 +61,102 @@ _ProcessEvents( { case vtkCommand::MouseMoveEvent: { - if( s->HandleObservers && s->HasObserver( vtkCommand::MouseMoveEvent ) ) - s->InvokeEvent( vtkCommand::MouseMoveEvent, NULL ); - else - s->OnMouseMove( ); + s->OnMouseMove( ); } break; case vtkCommand::LeftButtonPressEvent: { - long tick_count = - std::chrono::duration_cast< std::chrono::milliseconds >( - std::chrono::system_clock::now( ).time_since_epoch( ) - ).count( ); - if( - s->LastButtonHeld < Self::MAX_DOUBLE_CLICK && - ( tick_count - s->LastButtonUp ) < Self::MAX_DOUBLE_CLICK - ) - { - std::cout << "double!!!" << std::endl; - } - else - { - std::cout << "single!!!" << std::endl; - - } // fi - if( s->LastButtonDown < 0 ) - s->LastButtonDown = tick_count; - - /* - if( s->LastButton != Self::ButtonID_Left ) - { - s->LastButton = Self::ButtonID_Left; - s->LastButtonClicks = 1; - s->LastButtonTime = std::chrono::system_clock::now( ); - } - else if( s->LastButton == Self::ButtonID_Left ) - s->LastButtonClicks++; - */ + unsigned char nc = s->LeftButtonEvent.Clicks( ); + if( nc == 2 ) + s->OnLeftDoubleClick( ); + else if( nc == 1 ) + s->OnLeftClick( ); + s->ActiveButton = Self::ButtonID_Left; } break; case vtkCommand::LeftButtonReleaseEvent: { - long tick_count = - std::chrono::duration_cast< std::chrono::milliseconds >( - std::chrono::system_clock::now( ).time_since_epoch( ) - ).count( ); - s->LastButtonUp = tick_count; - s->LastButtonHeld = tick_count - s->LastButtonDown; - s->LastButtonDown = -1; - - /* - if( s->LastButton == Self::ButtonID_Left ) - { - long d = std::chrono::duration_cast< std::chrono::milliseconds >( - std::chrono::system_clock::now( ) - s->LastButtonTime - ).count( ); - if( d < 500 ) - { - } // fi - - } // fi - */ + s->LeftButtonEvent.Release( ); + s->ActiveButton = Self::ButtonID_None; } break; case vtkCommand::MiddleButtonPressEvent: { + unsigned char nc = s->MiddleButtonEvent.Clicks( ); + if( nc == 2 ) + s->OnMiddleDoubleClick( ); + else if( nc == 1 ) + s->OnMiddleClick( ); + s->ActiveButton = Self::ButtonID_Middle; } break; case vtkCommand::MiddleButtonReleaseEvent: { + s->MiddleButtonEvent.Release( ); + s->ActiveButton = Self::ButtonID_None; } break; case vtkCommand::RightButtonPressEvent: { + unsigned char nc = s->RightButtonEvent.Clicks( ); + if( nc == 2 ) + s->OnRightDoubleClick( ); + else if( nc == 1 ) + s->OnRightClick( ); + s->ActiveButton = Self::ButtonID_Right; } break; case vtkCommand::RightButtonReleaseEvent: { + s->RightButtonEvent.Release( ); + s->ActiveButton = Self::ButtonID_None; } break; case vtkCommand::MouseWheelForwardEvent: { - if( s->HandleObservers && s->HasObserver( vtkCommand::MouseWheelForwardEvent ) ) - s->InvokeEvent( vtkCommand::MouseWheelForwardEvent, NULL ); - else - s->OnMouseWheelForward( ); + s->OnMouseWheelForward( ); } break; case vtkCommand::MouseWheelBackwardEvent: { - if( s->HandleObservers && s->HasObserver( vtkCommand::MouseWheelBackwardEvent ) ) - s->InvokeEvent( vtkCommand::MouseWheelBackwardEvent, NULL ); - else - s->OnMouseWheelBackward( ); + s->OnMouseWheelBackward( ); } break; case vtkCommand::KeyPressEvent: { - if( s->HandleObservers && s->HasObserver( vtkCommand::KeyPressEvent ) ) - s->InvokeEvent( vtkCommand::KeyPressEvent, NULL ); - else - { - s->OnKeyDown( ); - s->OnKeyPress( ); - - } // fi + s->OnKeyDown( ); + s->OnKeyPress( ); } break; case vtkCommand::KeyReleaseEvent: { - if( s->HandleObservers && s->HasObserver( vtkCommand::KeyReleaseEvent ) ) - s->InvokeEvent( vtkCommand::KeyReleaseEvent, NULL ); - else - { - s->OnKeyUp( ); - s->OnKeyRelease( ); - - } // fi + s->OnKeyUp( ); + s->OnKeyRelease( ); } break; case vtkCommand::CharEvent: { - if( s->HandleObservers && s->HasObserver( vtkCommand::CharEvent ) ) - s->InvokeEvent( vtkCommand::CharEvent, NULL ); - else - s->OnChar( ); + s->OnChar( ); } break; case vtkCommand::ExposeEvent: { - if( s->HandleObservers && s->HasObserver( vtkCommand::ExposeEvent ) ) - s->InvokeEvent( vtkCommand::ExposeEvent, NULL ); - else - s->OnExpose( ); + s->OnExpose( ); } break; case vtkCommand::ConfigureEvent: { - if( s->HandleObservers && s->HasObserver( vtkCommand::ConfigureEvent ) ) - s->InvokeEvent( vtkCommand::ConfigureEvent, NULL ); - else - s->OnConfigure( ); + s->OnConfigure( ); } break; case vtkCommand::EnterEvent: { - if( s->HandleObservers && s->HasObserver( vtkCommand::EnterEvent ) ) - s->InvokeEvent( vtkCommand::EnterEvent, NULL ); - else - s->OnEnter( ); + s->OnEnter( ); } break; case vtkCommand::LeaveEvent: { - if( s->HandleObservers && s->HasObserver( vtkCommand::LeaveEvent ) ) - s->InvokeEvent( vtkCommand::LeaveEvent, NULL ); - else - s->OnLeave( ); + s->OnLeave( ); } break; case vtkCommand::TimerEvent: diff --git a/lib/cpExtensions/Visualization/BaseInteractorStyle.h b/lib/cpExtensions/Visualization/BaseInteractorStyle.h index f10a9bb..02dd150 100644 --- a/lib/cpExtensions/Visualization/BaseInteractorStyle.h +++ b/lib/cpExtensions/Visualization/BaseInteractorStyle.h @@ -3,8 +3,25 @@ #include +#include #include +/* + * Compile ITK and VTK with: cmake -DCMAKE_CXX_FLAGS="-std=c++11" /dir/to/source + */ + +/* ========================================================================= + * Double click algorithm taken from: + * http://www.autohotkey.com/board/topic/56493-easiest-way-to-detect-double-clicks/ + * ========================================================================= + */ + +// ------------------------------------------------------------------------- +#define BaseInteractorStyle_DIFF_TIME \ + std::chrono::duration_cast< std::chrono::milliseconds >( \ + std::chrono::system_clock::now( ).time_since_epoch( ) \ + ).count( ) + namespace cpExtensions { namespace Visualization @@ -20,10 +37,10 @@ namespace cpExtensions enum ButtonID { - ButtonID_None = 0x00, - ButtonID_Left = 0x01, - ButtonID_Middle = 0x02, - ButtonID_Right = 0x03 + ButtonID_None = 0, + ButtonID_Left, + ButtonID_Middle, + ButtonID_Right }; public: @@ -37,6 +54,8 @@ namespace cpExtensions virtual void OnMouseWheelBackward( ) { } // Possible mouse click-related events + inline ButtonID GetButtonID( ) const + { return( this->ActiveButton ); } virtual void OnLeftButtonDown( ) { } virtual void OnLeftButtonUp( ) { } virtual void OnLeftClick( ) { } @@ -103,11 +122,55 @@ namespace cpExtensions Self& operator=( const Self& ); protected: - static const long MAX_DOUBLE_CLICK; - ButtonID LastButton; - long LastButtonUp; - long LastButtonHeld; - long LastButtonDown; + + /** + * Button events + */ + struct MouseButtonEvent + { + static const long MAX_DOUBLE_CLICK; + long LastButtonUp; + long LastButtonHeld; + long LastButtonDown; + + inline MouseButtonEvent( ) + { this->Reset( ); } + inline void Reset( ) + { + this->LastButtonUp = 0; + this->LastButtonHeld = 0; + this->LastButtonDown = -1; + } + inline void Release( ) + { + long c = BaseInteractorStyle_DIFF_TIME; + this->LastButtonUp = c; + this->LastButtonHeld = c - this->LastButtonDown; + this->LastButtonDown = -1; + } + inline unsigned char Clicks( ) + { + unsigned char n = 0; + long c = BaseInteractorStyle_DIFF_TIME; + if( + this->LastButtonHeld < MAX_DOUBLE_CLICK && + ( c - this->LastButtonUp ) < MAX_DOUBLE_CLICK + ) + { + this->Reset( ); + n = 2; + } + else + n = 1; + if( this->LastButtonDown < 0 ) + this->LastButtonDown = c; + return( n ); + } + }; + MouseButtonEvent LeftButtonEvent; + MouseButtonEvent MiddleButtonEvent; + MouseButtonEvent RightButtonEvent; + ButtonID ActiveButton; }; } // ecapseman diff --git a/lib/cpExtensions/Visualization/ImageInteractorStyle.cxx b/lib/cpExtensions/Visualization/ImageInteractorStyle.cxx index b784808..aa688bf 100644 --- a/lib/cpExtensions/Visualization/ImageInteractorStyle.cxx +++ b/lib/cpExtensions/Visualization/ImageInteractorStyle.cxx @@ -1,5 +1,304 @@ #include +#include +#include + +// ------------------------------------------------------------------------- +cpExtensions::Visualization::ImageInteractorStyle:: +Self* cpExtensions::Visualization::ImageInteractorStyle:: +New( ) +{ + return( new Self ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageInteractorStyle:: +AssociateView( void* data ) +{ + this->Data = data; +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageInteractorStyle:: +AssociateImageActor( vtkImageActor* actor ) +{ + this->PropPicker->AddPickList( actor ); + this->Modified( ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageInteractorStyle:: +OnMouseMove( ) +{ + // Get current position on the associated actors + vtkRenderWindowInteractor* rwi = this->GetInteractor( ); + if( rwi == NULL || this->MouseMoveCommand == NULL ) + return; + double pos[ 3 ]; + if( !( this->_PickPosition( pos ) ) ) + return; + + // Get modifiers + bool alt = ( rwi->GetAltKey( ) == 1 ); + bool ctr = ( rwi->GetControlKey( ) == 1 ); + bool sft = ( rwi->GetShiftKey( ) == 1 ); + ButtonID button = this->GetButtonID( ); + + // Invoke possible events + this->MouseMoveCommand( this->Data, button, pos, alt, ctr, sft ); + rwi->Render( ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageInteractorStyle:: +OnMouseWheelForward( ) +{ + vtkRenderWindowInteractor* rwi = this->GetInteractor( ); + if( rwi == NULL || this->MouseWheelCommand == NULL ) + return; + + // Get modifiers + bool alt = ( rwi->GetAltKey( ) == 1 ); + bool ctr = ( rwi->GetControlKey( ) == 1 ); + bool sft = ( rwi->GetShiftKey( ) == 1 ); + + // Invoke possible events + this->MouseWheelCommand( this->Data, 1, alt, ctr, sft ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageInteractorStyle:: +OnMouseWheelBackward( ) +{ + vtkRenderWindowInteractor* rwi = this->GetInteractor( ); + if( rwi == NULL || this->MouseWheelCommand == NULL ) + return; + + // Get modifiers + bool alt = ( rwi->GetAltKey( ) == 1 ); + bool ctr = ( rwi->GetControlKey( ) == 1 ); + bool sft = ( rwi->GetShiftKey( ) == 1 ); + + // Invoke possible events + this->MouseWheelCommand( this->Data, -1, alt, ctr, sft ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageInteractorStyle:: +OnLeftClick( ) +{ + // Get current position on the associated actors + vtkRenderWindowInteractor* rwi = this->GetInteractor( ); + if( rwi == NULL || this->MouseClickCommand == NULL ) + return; + double pos[ 3 ]; + if( !( this->_PickPosition( pos ) ) ) + return; + + // Get modifiers + bool alt = ( rwi->GetAltKey( ) == 1 ); + bool ctr = ( rwi->GetControlKey( ) == 1 ); + bool sft = ( rwi->GetShiftKey( ) == 1 ); + + // Invoke possible events + this->MouseClickCommand( this->Data, Self::ButtonID_Left, pos, alt, ctr, sft ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageInteractorStyle:: +OnLeftDoubleClick( ) +{ + // Get current position on the associated actors + vtkRenderWindowInteractor* rwi = this->GetInteractor( ); + if( rwi == NULL || this->MouseDoubleClickCommand == NULL ) + return; + double pos[ 3 ]; + if( !( this->_PickPosition( pos ) ) ) + return; + + // Get modifiers + bool alt = ( rwi->GetAltKey( ) == 1 ); + bool ctr = ( rwi->GetControlKey( ) == 1 ); + bool sft = ( rwi->GetShiftKey( ) == 1 ); + + // Invoke possible events + this->MouseDoubleClickCommand( this->Data, Self::ButtonID_Left, pos, alt, ctr, sft ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageInteractorStyle:: +OnMiddleClick( ) +{ + // Get current position on the associated actors + vtkRenderWindowInteractor* rwi = this->GetInteractor( ); + if( rwi == NULL || this->MouseClickCommand == NULL ) + return; + double pos[ 3 ]; + if( !( this->_PickPosition( pos ) ) ) + return; + + // Get modifiers + bool alt = ( rwi->GetAltKey( ) == 1 ); + bool ctr = ( rwi->GetControlKey( ) == 1 ); + bool sft = ( rwi->GetShiftKey( ) == 1 ); + + // Invoke possible events + this->MouseClickCommand( this->Data, Self::ButtonID_Middle, pos, alt, ctr, sft ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageInteractorStyle:: +OnMiddleDoubleClick( ) +{ + // Get current position on the associated actors + vtkRenderWindowInteractor* rwi = this->GetInteractor( ); + if( rwi == NULL || this->MouseDoubleClickCommand == NULL ) + return; + double pos[ 3 ]; + if( !( this->_PickPosition( pos ) ) ) + return; + + // Get modifiers + bool alt = ( rwi->GetAltKey( ) == 1 ); + bool ctr = ( rwi->GetControlKey( ) == 1 ); + bool sft = ( rwi->GetShiftKey( ) == 1 ); + + // Invoke possible events + this->MouseDoubleClickCommand( this->Data, Self::ButtonID_Middle, pos, alt, ctr, sft ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageInteractorStyle:: +OnRightClick( ) +{ + // Get current position on the associated actors + vtkRenderWindowInteractor* rwi = this->GetInteractor( ); + if( rwi == NULL || this->MouseClickCommand == NULL ) + return; + double pos[ 3 ]; + if( !( this->_PickPosition( pos ) ) ) + return; + + // Get modifiers + bool alt = ( rwi->GetAltKey( ) == 1 ); + bool ctr = ( rwi->GetControlKey( ) == 1 ); + bool sft = ( rwi->GetShiftKey( ) == 1 ); + + // Invoke possible events + this->MouseClickCommand( this->Data, Self::ButtonID_Right, pos, alt, ctr, sft ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageInteractorStyle:: +OnRightDoubleClick( ) +{ + // Get current position on the associated actors + vtkRenderWindowInteractor* rwi = this->GetInteractor( ); + if( rwi == NULL || this->MouseDoubleClickCommand == NULL ) + return; + double pos[ 3 ]; + if( !( this->_PickPosition( pos ) ) ) + return; + + // Get modifiers + bool alt = ( rwi->GetAltKey( ) == 1 ); + bool ctr = ( rwi->GetControlKey( ) == 1 ); + bool sft = ( rwi->GetShiftKey( ) == 1 ); + + // Invoke possible events + this->MouseDoubleClickCommand( this->Data, Self::ButtonID_Right, pos, alt, ctr, sft ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageInteractorStyle:: +OnChar( ) +{ + vtkRenderWindowInteractor* rwi = this->GetInteractor( ); + if( rwi == NULL || this->KeyCommand == NULL ) + return; + this->KeyCommand( this->Data, rwi->GetKeyCode( ) ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageInteractorStyle:: +OnExpose( ) +{ + vtkRenderWindowInteractor* rwi = this->GetInteractor( ); + if( rwi == NULL ) + return; +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageInteractorStyle:: +OnConfigure( ) +{ + vtkRenderWindowInteractor* rwi = this->GetInteractor( ); + if( rwi == NULL ) + return; +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageInteractorStyle:: +OnEnter( ) +{ + vtkRenderWindowInteractor* rwi = this->GetInteractor( ); + if( rwi == NULL ) + return; +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageInteractorStyle:: +OnLeave( ) +{ + vtkRenderWindowInteractor* rwi = this->GetInteractor( ); + if( rwi == NULL ) + return; +} + +// ------------------------------------------------------------------------- +cpExtensions::Visualization::ImageInteractorStyle:: +ImageInteractorStyle( ) + : Superclass( ), + Data( NULL ), + MouseMoveCommand( NULL ), + MouseClickCommand( NULL ), + MouseDoubleClickCommand( NULL ), + MouseWheelCommand( NULL ), + KeyCommand( NULL ) +{ + this->PropPicker = vtkSmartPointer< vtkPropPicker >::New( ); + this->PropPicker->PickFromListOn( ); +} + +// ------------------------------------------------------------------------- +cpExtensions::Visualization::ImageInteractorStyle:: +~ImageInteractorStyle( ) +{ +} + +// ------------------------------------------------------------------------- +bool cpExtensions::Visualization::ImageInteractorStyle:: +_PickPosition( double pos[ 3 ] ) +{ + vtkRenderWindowInteractor* rwi = this->GetInteractor( ); + if( rwi == NULL ) + return( false ); + + // Find the renderer where the event has been raised + double x = double( rwi->GetEventPosition( )[ 0 ] ); + double y = double( rwi->GetEventPosition( )[ 1 ] ); + this->FindPokedRenderer( x, y ); + + // Pick a 3D position + int r = this->PropPicker->Pick( x, y, double( 0 ), this->CurrentRenderer ); + if( r == 0 ) + return( false ); + this->PropPicker->GetPickPosition( pos ); + + return( true ); +} + +/* #include #include @@ -682,5 +981,6 @@ _UpdateRadius( ) this->Interactor->Render( ); } +*/ // eof - $RCSfile$ diff --git a/lib/cpExtensions/Visualization/ImageInteractorStyle.h b/lib/cpExtensions/Visualization/ImageInteractorStyle.h index df8422c..e58c28d 100644 --- a/lib/cpExtensions/Visualization/ImageInteractorStyle.h +++ b/lib/cpExtensions/Visualization/ImageInteractorStyle.h @@ -1,68 +1,156 @@ #ifndef __CPEXTENSIONS__VISUALIZATION__IMAGEINTERACTORSTYLE__H__ #define __CPEXTENSIONS__VISUALIZATION__IMAGEINTERACTORSTYLE__H__ -#include +#include -#include -#include -#include #include +#include + +/* TODO + #include + + #include + #include -#include + #include -// ------------------------------------------------------------------------- -#define cpPlugins_ImageInteractorStyle_ObserverMacro( e ) \ - inline unsigned long Add##e##Observer( vtkCommand* observer ) \ - { return( this->AddObserver( Self::e##Event, observer ) ); } \ - inline void Remove##e##Observer( unsigned long tag ) \ - { this->RemoveObserver( tag ); } \ - inline void Remove##e##Observer( vtkCommand* observer ) \ - { this->RemoveObserver( observer ); } \ - inline void Remove##e##Observers( ) \ - { this->RemoveObservers( Self::e##Event ); } + // ------------------------------------------------------------------------- + #define cpPlugins_ImageInteractorStyle_ObserverMacro( e ) \ + inline unsigned long Add##e##Observer( vtkCommand* observer ) \ + { return( this->AddObserver( Self::e##Event, observer ) ); } \ + inline void Remove##e##Observer( unsigned long tag ) \ + { this->RemoveObserver( tag ); } \ + inline void Remove##e##Observer( vtkCommand* observer ) \ + { this->RemoveObserver( observer ); } \ + inline void Remove##e##Observers( ) \ + { this->RemoveObservers( Self::e##Event ); } +*/ + +// Forward definitions +class vtkImageActor; namespace cpExtensions { namespace Visualization { - class ImageSliceActors; - class MPRActors; - /** */ class cpExtensions_EXPORT ImageInteractorStyle - : public vtkInteractorStyleImage + : public BaseInteractorStyle { public: typedef ImageInteractorStyle Self; + vtkTypeMacro( ImageInteractorStyle, BaseInteractorStyle ); + + public: + typedef void ( *TMouseCommand )( void*, const ButtonID&, double*, bool, bool, bool ); + typedef void ( *TMouseWheelCommand )( void*, const int&, bool, bool, bool ); + typedef void ( *TKeyCommand )( void*, const char& ); + + vtkGetMacro( MouseMoveCommand, TMouseCommand ); + vtkGetMacro( MouseClickCommand, TMouseCommand ); + vtkGetMacro( MouseDoubleClickCommand, TMouseCommand ); + vtkGetMacro( MouseWheelCommand, TMouseWheelCommand ); + vtkGetMacro( KeyCommand, TKeyCommand ); + + vtkSetMacro( MouseMoveCommand, TMouseCommand ); + vtkSetMacro( MouseClickCommand, TMouseCommand ); + vtkSetMacro( MouseDoubleClickCommand, TMouseCommand ); + vtkSetMacro( MouseWheelCommand, TMouseWheelCommand ); + vtkSetMacro( KeyCommand, TKeyCommand ); + + public: + static Self* New( ); + + virtual void AssociateView( void* data ); + virtual void AssociateImageActor( vtkImageActor* actor ); + + // Possible mouse motion events + virtual void OnMouseMove( ); + virtual void OnMouseWheelForward( ); + virtual void OnMouseWheelBackward( ); + + // Possible mouse click-related events + virtual void OnLeftClick( ); + virtual void OnLeftDoubleClick( ); + virtual void OnMiddleClick( ); + virtual void OnMiddleDoubleClick( ); + virtual void OnRightClick( ); + virtual void OnRightDoubleClick( ); + + // Keyboard-related events + virtual void OnChar( ); + + // Other events + virtual void OnExpose( ); + virtual void OnConfigure( ); + virtual void OnEnter( ); + virtual void OnLeave( ); + + protected: + ImageInteractorStyle( ); + virtual ~ImageInteractorStyle( ); + + bool _PickPosition( double pos[ 3 ] ); + + private: + // Purposely not implemented + ImageInteractorStyle( const Self& ); + Self& operator=( const Self& ); + + protected: + vtkSmartPointer< vtkPropPicker > PropPicker; + + // Commands + void* Data; + TMouseCommand MouseMoveCommand; + TMouseCommand MouseClickCommand; + TMouseCommand MouseDoubleClickCommand; + TMouseWheelCommand MouseWheelCommand; + TKeyCommand KeyCommand; + }; + + /* + class ImageSliceActors; + class MPRActors; + */ + + /** + */ + /* + class cpExtensions_EXPORT ImageInteractorStyle + : public vtkInteractorStyleImage + { + public: + typedef ImageInteractorStyle Self; enum InteractionMode { - NavigationMode = 0, - DeformationMode + NavigationMode = 0, + DeformationMode }; - public: + public: vtkTypeMacro( ImageInteractorStyle, vtkInteractorStyleImage ); cpPlugins_ImageInteractorStyle_ObserverMacro( DoubleClick ); cpPlugins_ImageInteractorStyle_ObserverMacro( Cursor ); cpPlugins_ImageInteractorStyle_ObserverMacro( Radius ); - public: + public: static Self* New( ); void Configure( - ImageSliceActors* slice_actors, - MPRActors* mpr_actors = NULL - ); + ImageSliceActors* slice_actors, + MPRActors* mpr_actors = NULL + ); void AssociateInteractor( vtkRenderWindowInteractor* interactor ); void SetModeToNavigation( ); void SetModeToDeformation( ); virtual void SetInteractor( - vtkRenderWindowInteractor* interactor, const int& axis - ); + vtkRenderWindowInteractor* interactor, const int& axis + ); // Description: // Event bindings controlling the effects of pressing mouse buttons @@ -108,28 +196,26 @@ namespace cpExtensions virtual void StartRadiusMoving( ); virtual void EndRadiusMoving( ); - protected: + protected: ImageInteractorStyle( ); virtual ~ImageInteractorStyle( ); void _RenderAssociateInteractors( ); - bool _PickPosition( double pos[ 3 ] ); void _UpdateCursor( ); void _UpdateRadius( ); - private: + private: // Purposely not implemented ImageInteractorStyle( const Self& ); Self& operator=( const Self& ); - protected: + protected: Self::InteractionMode Mode; ImageSliceActors* m_SliceActors; MPRActors* m_MPRActors; vtkSmartPointer< vtkOrientationMarkerWidget > OrientationWidget; - vtkSmartPointer< vtkPropPicker > PropPicker; std::vector< vtkRenderWindowInteractor* > AssociatedInteractors; @@ -142,11 +228,12 @@ namespace cpExtensions vtkSmartPointer< vtkPolyDataMapper > CircleMapper; vtkSmartPointer< vtkActor > CircleActor; - public: + public: static const int CursorEvent; static const int RadiusEvent; static const int DoubleClickEvent; - }; + }; + */ } // ecapseman diff --git a/lib/cpExtensions/Visualization/ImageSliceActors.cxx b/lib/cpExtensions/Visualization/ImageSliceActors.cxx index 469f270..5722c58 100644 --- a/lib/cpExtensions/Visualization/ImageSliceActors.cxx +++ b/lib/cpExtensions/Visualization/ImageSliceActors.cxx @@ -1,5 +1,7 @@ #include +#include + #include #include #include @@ -7,6 +9,7 @@ #include #include #include +#include #include #include @@ -50,7 +53,7 @@ Clear( ) // Delete all images this->SliceMappers.clear( ); this->ImageActors.clear( ); - this->OtherActors.clear( ); + this->AssociatedActors.clear( ); // Reconfigure unique objects this->PlaneFunction = vtkSmartPointer< vtkPlane >::New( ); @@ -97,6 +100,44 @@ Clear( ) coord->SetValue( 0.01, 0.01 ); } +// ------------------------------------------------------------------------- +vtkInteractorStyle* cpExtensions::Visualization::ImageSliceActors:: +GetStyle( ) +{ + return( this->Style.GetPointer( ) ); +} + +// ------------------------------------------------------------------------- +const vtkInteractorStyle* cpExtensions::Visualization::ImageSliceActors:: +GetStyle( ) const +{ + return( this->Style.GetPointer( ) ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageSliceActors:: +PushActorsInto( vtkRenderer* renderer ) +{ + unsigned int N = this->GetNumberOfImageActors( ); + for( unsigned int n = 0; n < N; ++n ) + renderer->AddActor( this->GetImageActor( n ) ); + renderer->AddActor( this->GetTextActor( ) ); + renderer->AddActor( this->GetPlaneActor( ) ); + renderer->Modified( ); +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageSliceActors:: +PopActorsFrom( vtkRenderer* renderer ) +{ + unsigned int N = this->GetNumberOfImageActors( ); + for( unsigned int n = 0; n < N; ++n ) + renderer->RemoveActor( this->GetImageActor( n ) ); + renderer->RemoveActor( this->GetTextActor( ) ); + renderer->RemoveActor( this->GetPlaneActor( ) ); + renderer->Modified( ); +} + // ------------------------------------------------------------------------- unsigned int cpExtensions::Visualization::ImageSliceActors:: GetNumberOfImageActors( ) const @@ -170,7 +211,7 @@ GetPlaneFunction( ) const void cpExtensions::Visualization::ImageSliceActors:: AddActor( vtkAlgorithm* algorithm, vtkActor* actor ) { - this->OtherActors.push_back( TActorPair( algorithm, actor ) ); + this->AssociatedActors.push_back( TAssociatedActor( algorithm, actor ) ); this->AddItem( actor ); } @@ -381,26 +422,28 @@ SetSliceNumber( const int& slice ) this->PlaneActor->Modified( ); // Prepare other actors to update - for( unsigned int i = 0; i < this->OtherActors.size( ); ++i ) - { - if( this->OtherActors[ i ].first.GetPointer( ) != NULL ) - { - this->OtherActors[ i ].first->Modified( ); - this->OtherActors[ i ].first->Update( ); + /* TODO + for( unsigned int i = 0; i < this->OtherActors.size( ); ++i ) + { + if( this->OtherActors[ i ].first.GetPointer( ) != NULL ) + { + this->OtherActors[ i ].first->Modified( ); + this->OtherActors[ i ].first->Update( ); - } // fi + } // fi - if( this->OtherActors[ i ].second.GetPointer( ) != NULL ) - { - this->OtherActors[ i ].second->GetMapper( )->Modified( ); - this->OtherActors[ i ].second->Modified( ); + if( this->OtherActors[ i ].second.GetPointer( ) != NULL ) + { + this->OtherActors[ i ].second->GetMapper( )->Modified( ); + this->OtherActors[ i ].second->Modified( ); - } // fi + } // fi - } // rof + } // rof - if( this->m_UpdateCommand != NULL ) - this->m_UpdateCommand( this->m_UpdateData ); + if( this->m_UpdateCommand != NULL ) + this->m_UpdateCommand( this->m_UpdateData ); + */ // Update text this->UpdateText( ); @@ -430,6 +473,57 @@ UpdateText( ) this->Modified( ); } +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageSliceActors:: +UpdateText( double pos[ 3 ] ) +{ + if( this->SliceMappers.size( ) > 0 ) + { + char axis; + int axId = this->SliceMappers[ 0 ]->GetOrientation( ); + if ( axId == 0 ) axis = 'X'; + else if( axId == 1 ) axis = 'Y'; + else if( axId == 2 ) axis = 'Z'; + + vtkImageData* image = this->SliceMappers[ 0 ]->GetInput( ); + + int ijk[ 3 ]; + double pcoords[ 3 ]; + image->ComputeStructuredCoordinates( pos, ijk, pcoords ); + { + int nScl = image->GetNumberOfScalarComponents( ); + std::stringstream str; + str + << "[" << ijk[ 0 ] + << "," << ijk[ 1 ] + << "," << ijk[ 2 ] << "]=("; + str << + image->GetScalarComponentAsFloat( + ijk[ 0 ], ijk[ 1 ], ijk[ 2 ], 0 + ); + for( int n = 1; n < nScl; ++n ) + str + << " " + << image->GetScalarComponentAsFloat( + ijk[ 0 ], ijk[ 1 ], ijk[ 2 ], n + ); + str << ")"; + std::sprintf( + this->TextBuffer, "Axis: %c (%d) | Pixel %s", + axis, + this->SliceMappers[ 0 ]->GetSliceNumber( ), + str.str( ).c_str( ) + ); + + } // fi + } + else + this->TextBuffer[ 0 ] = '\0'; + this->TextActor->SetInput( this->TextBuffer ); + this->TextActor->Modified( ); + this->Modified( ); +} + // ------------------------------------------------------------------------- void cpExtensions::Visualization::ImageSliceActors:: UpdateText( const double& w, const double& l ) @@ -458,10 +552,17 @@ UpdateText( const double& w, const double& l ) cpExtensions::Visualization::ImageSliceActors:: ImageSliceActors( ) : Superclass( ), - Interpolate( false ), - m_UpdateCommand( NULL ), - m_UpdateData( NULL ) + Interpolate( false ) { + // Connect this view with a controller + this->Style = vtkSmartPointer< ImageInteractorStyle >::New( ); + this->Style->AssociateView( this ); + this->Style->SetMouseMoveCommand( Self::_MouseMoveCommand ); + this->Style->SetMouseClickCommand( Self::_MouseClickCommand ); + this->Style->SetMouseDoubleClickCommand( Self::_MouseDoubleClickCommand ); + this->Style->SetMouseWheelCommand( Self::_MouseWheelCommand ); + this->Style->SetKeyCommand( Self::_KeyCommand ); + this->Clear( ); } @@ -497,6 +598,7 @@ _ConfigureNewInput( int axis ) { this->AddItem( this->TextActor ); this->AddItem( this->PlaneActor ); + this->Style->AssociateImageActor( actor ); } // fi this->AddItem( actor ); @@ -506,4 +608,69 @@ _ConfigureNewInput( int axis ) this->Modified( ); } +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageSliceActors:: +_MouseMoveCommand( + void* data, + const ImageInteractorStyle::ButtonID& btn, double* pos, + bool alt, bool ctr, bool sft + ) +{ + ImageSliceActors* actors = reinterpret_cast< ImageSliceActors* >( data ); + if( actors == NULL ) + return; + + if( btn == ImageInteractorStyle::ButtonID_None ) + { + actors->UpdateText( pos ); + } + else if( btn == ImageInteractorStyle::ButtonID_Left ) + { + } + else if( btn == ImageInteractorStyle::ButtonID_Middle ) + { + } + else if( btn == ImageInteractorStyle::ButtonID_Right ) + { + } // fi +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageSliceActors:: +_MouseClickCommand( + void* data, + const ImageInteractorStyle::ButtonID& btn, double* pos, + bool alt, bool ctr, bool sft + ) +{ +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageSliceActors:: +_MouseDoubleClickCommand( + void* data, + const ImageInteractorStyle::ButtonID& btn, double* pos, + bool alt, bool ctr, bool sft + ) +{ +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageSliceActors:: +_MouseWheelCommand( + void* data, + const int& dir, bool alt, bool ctr, bool sft + ) +{ +} + +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::ImageSliceActors:: +_KeyCommand( + void* data, + const char& key + ) +{ +} + // eof - $RCSfile$ diff --git a/lib/cpExtensions/Visualization/ImageSliceActors.h b/lib/cpExtensions/Visualization/ImageSliceActors.h index 1a5bf49..f940a90 100644 --- a/lib/cpExtensions/Visualization/ImageSliceActors.h +++ b/lib/cpExtensions/Visualization/ImageSliceActors.h @@ -16,6 +16,8 @@ #include #include +#include + // ------------------------------------------------------------------------- class vtkAlgorithmOutput; class vtkImageData; @@ -33,8 +35,6 @@ namespace cpExtensions public: typedef ImageSliceActors Self; - typedef void ( *TUpdateCommand )( void* ); - public: vtkTypeMacro( ImageSliceActors, vtkPropCollection ); @@ -42,10 +42,15 @@ namespace cpExtensions // Creation static ImageSliceActors* New( ); - void AddInputConnection( vtkAlgorithmOutput* aout, int axis = 0 ); - void AddInputData( vtkImageData* data, int axis = 0 ); + void AddInputConnection( vtkAlgorithmOutput* aout, int axis = 2 ); + void AddInputData( vtkImageData* data, int axis = 2 ); void Clear( ); + vtkInteractorStyle* GetStyle( ); + const vtkInteractorStyle* GetStyle( ) const; + + void PushActorsInto( vtkRenderer* renderer ); + void PopActorsFrom( vtkRenderer* renderer ); unsigned int GetNumberOfImageActors( ) const; vtkImageActor* GetImageActor( unsigned int id ); const vtkImageActor* GetImageActor( unsigned int id ) const; @@ -72,36 +77,58 @@ namespace cpExtensions int GetSliceNumberMaxValue( ) const; void SetSliceNumber( const int& slice ); void UpdateText( ); + void UpdateText( double pos[ 3 ] ); void UpdateText( const double& w, const double& l ); - void SetUpdateCommand( TUpdateCommand cmd, void* data ) - { - this->m_UpdateCommand = cmd; - this->m_UpdateData = data; - } - protected: ImageSliceActors( ); virtual ~ImageSliceActors( ); void _ConfigureNewInput( int axis ); + // Events + static void _MouseMoveCommand( + void* data, + const ImageInteractorStyle::ButtonID& btn, double* pos, + bool alt, bool ctr, bool sft + ); + static void _MouseClickCommand( + void* data, + const ImageInteractorStyle::ButtonID& btn, double* pos, + bool alt, bool ctr, bool sft + ); + static void _MouseDoubleClickCommand( + void* data, + const ImageInteractorStyle::ButtonID& btn, double* pos, + bool alt, bool ctr, bool sft + ); + static void _MouseWheelCommand( + void* data, + const int& dir, bool alt, bool ctr, bool sft + ); + static void _KeyCommand( + void* data, + const char& key + ); + private: // Purposely not implemented ImageSliceActors( const Self& ); Self& operator=( const Self& ); protected: + vtkSmartPointer< ImageInteractorStyle > Style; + // Multiple actors std::vector< vtkSmartPointer< vtkImageSliceMapper > > SliceMappers; std::vector< vtkSmartPointer< vtkImageActor > > ImageActors; - - typedef - std::pair< vtkSmartPointer< vtkAlgorithm >, vtkSmartPointer< vtkActor > > - TActorPair; - std::vector< TActorPair > OtherActors; bool Interpolate; + // Other associated actors + typedef std::pair< vtkAlgorithm*, vtkActor* > TAssociatedActor; + typedef std::vector< TAssociatedActor > TAssociatedActors; + TAssociatedActors AssociatedActors; + // Unique objects vtkSmartPointer< vtkPlane > PlaneFunction; vtkSmartPointer< vtkPolyData > PlaneSource; @@ -109,10 +136,6 @@ namespace cpExtensions char TextBuffer[ 1024 ]; vtkSmartPointer< vtkTextActor > TextActor; vtkSmartPointer< vtkActor > PlaneActor; - - - TUpdateCommand m_UpdateCommand; - void* m_UpdateData; }; } // ecapseman diff --git a/lib/cpExtensions/Visualization/MPRObjects.cxx b/lib/cpExtensions/Visualization/MPRObjects.cxx index a32824c..0076ad5 100644 --- a/lib/cpExtensions/Visualization/MPRObjects.cxx +++ b/lib/cpExtensions/Visualization/MPRObjects.cxx @@ -95,7 +95,7 @@ ActivateInteractors( ) // Check prerrequisites if( this->m_Windows[ i ] == NULL || this->m_Renderers[ i ] == NULL ) { - this->m_Styles[ i ] = NULL; + // TODO: this->m_Styles[ i ] = NULL; continue; } // fi @@ -103,16 +103,18 @@ ActivateInteractors( ) ImageSliceActors* actors = this->m_MPRActors->GetSliceActors( i ); if( actors == NULL ) { - this->m_Styles[ i ] = NULL; + // TODO: this->m_Styles[ i ] = NULL; continue; } // fi - this->m_Styles[ i ] = vtkSmartPointer< TStyle >::New( ); - this->m_Styles[ i ]->Configure( actors, this->m_MPRActors ); - this->m_Styles[ i ]-> - SetInteractor( this->m_Windows[ i ]->GetInteractor( ), i ); - this->m_Styles[ i ]->SetModeToNavigation( ); + /* TODO + this->m_Styles[ i ] = vtkSmartPointer< TStyle >::New( ); + this->m_Styles[ i ]->Configure( actors, this->m_MPRActors ); + this->m_Styles[ i ]-> + SetInteractor( this->m_Windows[ i ]->GetInteractor( ), i ); + this->m_Styles[ i ]->SetModeToNavigation( ); + */ } // rof @@ -121,18 +123,22 @@ ActivateInteractors( ) { for( int j = 0; j < 3; ++j ) { - if( - this->m_Windows[ i ] != NULL && - this->m_Windows[ j ] != NULL && - i != j - ) - this->m_Styles[ i ]-> - AssociateInteractor( this->m_Windows[ j ]->GetInteractor( ) ); + /* TODO + if( + this->m_Windows[ i ] != NULL && + this->m_Windows[ j ] != NULL && + i != j + ) + this->m_Styles[ i ]-> + AssociateInteractor( this->m_Windows[ j ]->GetInteractor( ) ); + */ } // rof - if( this->m_Windows[ 3 ] != NULL ) - this->m_Styles[ i ]-> - AssociateInteractor( this->m_Windows[ 3 ]->GetInteractor( ) ); + /* TODO + if( this->m_Windows[ 3 ] != NULL ) + this->m_Styles[ i ]-> + AssociateInteractor( this->m_Windows[ 3 ]->GetInteractor( ) ); + */ } // rof diff --git a/lib/cpExtensions/Visualization/MPRObjects.h b/lib/cpExtensions/Visualization/MPRObjects.h index cbec46f..7d33f3f 100644 --- a/lib/cpExtensions/Visualization/MPRObjects.h +++ b/lib/cpExtensions/Visualization/MPRObjects.h @@ -3,7 +3,6 @@ #include #include -#include #include #include @@ -20,8 +19,7 @@ namespace cpExtensions { public: typedef MPRObjects Self; - typedef cpExtensions::Visualization::MPRActors TMPRActors; - typedef cpExtensions::Visualization::ImageInteractorStyle TStyle; + typedef cpExtensions::Visualization::MPRActors TMPRActors; public: vtkTypeMacro( MPRObjects, vtkObject ); @@ -70,7 +68,6 @@ namespace cpExtensions // Internal pipelines vtkSmartPointer< TMPRActors > m_MPRActors; vtkSmartPointer< vtkRenderer > m_Renderers[ 4 ]; - vtkSmartPointer< TStyle > m_Styles[ 3 ]; }; } // ecapseman diff --git a/lib/cpPlugins/Interface/BaseProcessObjects.h b/lib/cpPlugins/Interface/BaseProcessObjects.h index 8ebd4e4..1b2c8db 100644 --- a/lib/cpPlugins/Interface/BaseProcessObjects.h +++ b/lib/cpPlugins/Interface/BaseProcessObjects.h @@ -5,32 +5,29 @@ #include // ------------------------------------------------------------------------- -#define cpPlugins_Define_ProcessObject( O, S ) \ - class cpPlugins_Interface_EXPORT O \ - : public S \ - { \ - public: \ - typedef O Self; \ - typedef S Superclass; \ - typedef itk::SmartPointer< Self > Pointer; \ - typedef itk::SmartPointer< const Self > ConstPointer; \ - public: \ - itkTypeMacro( O, S ); \ - protected: \ - O( ); \ - virtual ~O( ); \ - private: \ - O( const Self& ); \ - Self& operator=( const Self& ); \ +#define cpPlugins_Define_ProcessObject( O, S ) \ + class cpPlugins_Interface_EXPORT O \ + : public S \ + { \ + public: \ + typedef O Self; \ + typedef S Superclass; \ + typedef itk::SmartPointer< Self > Pointer; \ + typedef itk::SmartPointer< const Self > ConstPointer; \ + public: \ + itkTypeMacro( O, S ); \ + cpPlugins_Id_Macro( cpPlugins::Interface::O, "ProcessObject" ); \ + protected: \ + O( ); \ + virtual ~O( ); \ + private: \ + O( const Self& ); \ + Self& operator=( const Self& ); \ } // ------------------------------------------------------------------------- #define cpPlugins_Code_ProcessObject( O ) \ - cpPlugins::Interface::O::O( ) : Superclass( ) \ - { \ - this->m_ClassName = "cpPlugins::Interface::#O"; \ - this->m_ClassCategory = "#O"; \ - } \ + cpPlugins::Interface::O::O( ) : Superclass( ) { } \ cpPlugins::Interface::O::~O( ) { } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/DataObject.cxx b/lib/cpPlugins/Interface/DataObject.cxx index 536ea81..5804345 100644 --- a/lib/cpPlugins/Interface/DataObject.cxx +++ b/lib/cpPlugins/Interface/DataObject.cxx @@ -70,8 +70,6 @@ DataObject( ) m_VTKObject( NULL ), m_Source( NULL ) { - this->m_ClassName = "cpPlugins::Interface::DataObject"; - this->m_ClassCategory = "BasicObject"; } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/DataObject.h b/lib/cpPlugins/Interface/DataObject.h index 3347b64..841f3a2 100644 --- a/lib/cpPlugins/Interface/DataObject.h +++ b/lib/cpPlugins/Interface/DataObject.h @@ -26,6 +26,9 @@ namespace cpPlugins public: itkTypeMacro( DataObject, Object ); + cpPlugins_Id_Macro( + cpPlugins::Interface::DataObject, "BasicObject" + ); public: Object* GetSource( ); diff --git a/lib/cpPlugins/Interface/Image.cxx b/lib/cpPlugins/Interface/Image.cxx index ad7b3ad..48b9074 100644 --- a/lib/cpPlugins/Interface/Image.cxx +++ b/lib/cpPlugins/Interface/Image.cxx @@ -14,8 +14,6 @@ cpPlugins::Interface::Image:: Image( ) : Superclass( ) { - this->m_ClassName = "cpPlugins::Interface::Image"; - this->m_ClassCategory = "BasicObject"; } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/Image.h b/lib/cpPlugins/Interface/Image.h index 5d0d55b..1aeee5c 100644 --- a/lib/cpPlugins/Interface/Image.h +++ b/lib/cpPlugins/Interface/Image.h @@ -27,6 +27,9 @@ namespace cpPlugins public: itkNewMacro( Self ); itkTypeMacro( Image, DataObject ); + cpPlugins_Id_Macro( + cpPlugins::Interface::Image, "DataObject" + ); public: template< class I > diff --git a/lib/cpPlugins/Interface/Mesh.cxx b/lib/cpPlugins/Interface/Mesh.cxx index 0dc2f9a..2866967 100644 --- a/lib/cpPlugins/Interface/Mesh.cxx +++ b/lib/cpPlugins/Interface/Mesh.cxx @@ -65,8 +65,6 @@ Mesh( ) m_Mapper( NULL ), m_Actor( NULL ) { - this->m_ClassName = "cpPlugins::Interface::Mesh"; - this->m_ClassCategory = "BasicObject"; } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/Mesh.h b/lib/cpPlugins/Interface/Mesh.h index 20c56fb..0eb76ed 100644 --- a/lib/cpPlugins/Interface/Mesh.h +++ b/lib/cpPlugins/Interface/Mesh.h @@ -26,6 +26,9 @@ namespace cpPlugins public: itkNewMacro( Self ); itkTypeMacro( Mesh, DataObject ); + cpPlugins_Id_Macro( + cpPlugins::Interface::Mesh, "DataObject" + ); public: template< class M > diff --git a/lib/cpPlugins/Interface/Object.h b/lib/cpPlugins/Interface/Object.h index 5b0ebd6..c4a0bfb 100644 --- a/lib/cpPlugins/Interface/Object.h +++ b/lib/cpPlugins/Interface/Object.h @@ -54,8 +54,8 @@ public: \ // ------------------------------------------------------------------------- #define cpPlugins_Id_Macro( name, category ) \ public: \ - static std::string GetClassName( ) { return( #name ); } \ - static std::string GetClassCategory( ) { return( category ); } + virtual std::string GetClassName( ) { return( #name ); } \ + virtual std::string GetClassCategory( ) { return( category ); } namespace cpPlugins { diff --git a/lib/cpPlugins/Interface/ProcessObject.cxx b/lib/cpPlugins/Interface/ProcessObject.cxx index bc5f7f2..b2b9337 100644 --- a/lib/cpPlugins/Interface/ProcessObject.cxx +++ b/lib/cpPlugins/Interface/ProcessObject.cxx @@ -107,7 +107,7 @@ ExecConfigurationDialog( QWidget* parent ) Parameters parameters = this->m_DefaultParameters; r = cpPlugins::Interface::ParametersQtDialog( parameters, - this->m_ClassName + std::string( " basic configuration" ), + this->GetClassName( ) + std::string( " basic configuration" ), parent ); if( r ) @@ -125,8 +125,6 @@ ProcessObject( ) m_ITKObject( NULL ), m_VTKObject( NULL ) { - this->m_ClassName = "cpPlugins::Interface::ProcessObject"; - this->m_ClassCategory = "BasicObject"; } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/ProcessObject.h b/lib/cpPlugins/Interface/ProcessObject.h index 2a9fc91..b84ad3e 100644 --- a/lib/cpPlugins/Interface/ProcessObject.h +++ b/lib/cpPlugins/Interface/ProcessObject.h @@ -35,6 +35,9 @@ namespace cpPlugins public: itkTypeMacro( ProcessObject, Object ); + cpPlugins_Id_Macro( + cpPlugins::Interface::ProcessObject, "BaseObject" + ); public: virtual const Parameters& GetDefaultParameters( ) const; diff --git a/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx index 1a257a6..10704aa 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx @@ -8,8 +8,6 @@ cpPlugins::BasicFilters::BinaryThresholdImageFilter:: BinaryThresholdImageFilter( ) : Superclass( ) { - this->m_ClassName = "cpPlugins::BasicFilters::BinaryThresholdImageFilter"; - this->m_ClassCategory = "ImageToImageFilter"; this->SetNumberOfInputs( 1 ); this->SetNumberOfOutputs( 1 ); this->_MakeOutput< cpPlugins::Interface::Image >( 0 ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.h b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.h index 4658f9d..7bfa56c 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.h +++ b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.h @@ -25,6 +25,10 @@ namespace cpPlugins BinaryThresholdImageFilter, cpPluginsInterfaceImageToImageFilter ); + cpPlugins_Id_Macro( + cpPlugins::BasicFilters::BinaryThresholdImageFilter, + "ImageToImageFilter" + ); protected: BinaryThresholdImageFilter( ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx b/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx index c6ac99f..e0c80b4 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx @@ -13,9 +13,6 @@ cpPlugins::BasicFilters::Cutter:: Cutter( ) : Superclass( ) { - this->m_ClassName = "cpPlugins::BasicFilters::Cutter"; - this->m_ClassCategory = "MeshToMeshFilter"; - this->SetNumberOfInputs( 2 ); this->SetNumberOfOutputs( 1 ); this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/Cutter.h b/lib/cpPlugins/Plugins/BasicFilters/Cutter.h index 52438a7..8374bbc 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/Cutter.h +++ b/lib/cpPlugins/Plugins/BasicFilters/Cutter.h @@ -22,6 +22,10 @@ namespace cpPlugins public: itkNewMacro( Self ); itkTypeMacro( Cutter, cpPluginsInterfaceMeshToMeshFilter ); + cpPlugins_Id_Macro( + cpPlugins::BasicFilters::Cutter, + "MeshToMeshFilter" + ); protected: Cutter( ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.cxx index 378c5e2..88b3152 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.cxx @@ -8,8 +8,6 @@ cpPlugins::BasicFilters::ExtractSliceImageFilter:: ExtractSliceImageFilter( ) : Superclass( ) { - this->m_ClassName = "cpPlugins::BasicFilters::ExtractSliceImageFilter"; - this->m_ClassCategory = "ImageToImageFilter"; this->SetNumberOfInputs( 1 ); this->SetNumberOfOutputs( 1 ); this->_MakeOutput< cpPlugins::Interface::Image >( 0 ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.h b/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.h index a18e992..39414eb 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.h +++ b/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.h @@ -24,6 +24,10 @@ namespace cpPlugins itkTypeMacro( ExtractSliceImageFilter, cpPluginsInterfaceImageToImageFilter ); + cpPlugins_Id_Macro( + cpPlugins::BasicFilters::ExtractSliceImageFilter, + "ImageToImageFilter" + ); protected: ExtractSliceImageFilter( ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx b/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx index cca186c..9253860 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx @@ -11,9 +11,6 @@ cpPlugins::BasicFilters::MarchingCubes:: MarchingCubes( ) : Superclass( ) { - this->m_ClassName = "cpPlugins::BasicFilters::MarchingCubes"; - this->m_ClassCategory = "ImageToMeshFilter"; - this->SetNumberOfInputs( 1 ); this->SetNumberOfOutputs( 1 ); this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.h b/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.h index 3f9c22d..2e664e5 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.h +++ b/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.h @@ -22,6 +22,9 @@ namespace cpPlugins public: itkNewMacro( Self ); itkTypeMacro( MarchingCubes, cpPluginsInterfaceImageToMeshFilter ); + cpPlugins_Id_Macro( + cpPlugins::BasicFilters::MarchingCubes, "ImageToMeshFilter" + ); protected: MarchingCubes( ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx index df145b8..083c6b9 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx @@ -8,8 +8,6 @@ cpPlugins::BasicFilters::MedianImageFilter:: MedianImageFilter( ) : Superclass( ) { - this->m_ClassName = "cpPlugins::BasicFilters::MedianImageFilter"; - this->m_ClassCategory = "ImageToImageFilter"; this->SetNumberOfInputs( 1 ); this->SetNumberOfOutputs( 1 ); this->_MakeOutput< cpPlugins::Interface::Image >( 0 ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.h b/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.h index ea2bb61..1e491e7 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.h +++ b/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.h @@ -25,6 +25,10 @@ namespace cpPlugins MedianImageFilter, cpPluginsInterfaceImageToImageFilter ); + cpPlugins_Id_Macro( + cpPlugins::BasicFilters::MedianImageFilter, + "ImageToImageFilter" + ); protected: MedianImageFilter( ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx index de924a6..59f98f5 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx @@ -8,8 +8,6 @@ cpPlugins::BasicFilters::OtsuThresholdImageFilter:: OtsuThresholdImageFilter( ) : Superclass( ) { - this->m_ClassName = "cpPlugins::BasicFilters::OtsuThresholdImageFilter"; - this->m_ClassCategory = "ImageToImageFilter"; this->SetNumberOfInputs( 1 ); this->SetNumberOfOutputs( 1 ); this->_MakeOutput< cpPlugins::Interface::Image >( 0 ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.h b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.h index b717062..5f216dd 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.h +++ b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.h @@ -25,6 +25,10 @@ namespace cpPlugins OtsuThresholdImageFilter, cpPluginsInterfaceImageToImageFilter ); + cpPlugins_Id_Macro( + cpPlugins::BasicFilters::OtsuThresholdImageFilter, + "ImageToImageFilter" + ); protected: OtsuThresholdImageFilter( ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx index 38cec31..5282f60 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx @@ -13,8 +13,6 @@ RGBImageToOtherChannelsFilter( ) { typedef cpPlugins::Interface::Parameters TParameters; - this->m_ClassName = "cpPlugins::BasicFilters::RGBImageToOtherChannelsFilter"; - this->m_ClassCategory = "ImageToImageFilter"; this->SetNumberOfInputs( 1 ); this->SetNumberOfOutputs( 1 ); this->_MakeOutput< cpPlugins::Interface::Image >( 0 ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.h b/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.h index bb559c8..4a42a5d 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.h +++ b/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.h @@ -25,6 +25,10 @@ namespace cpPlugins RGBImageToOtherChannelsFilter, cpPluginsInterfaceImageToImageFilter ); + cpPlugins_Id_Macro( + cpPlugins::BasicFilters::RGBImageToOtherChannelsFilter, + "ImageToImageFilter" + ); protected: RGBImageToOtherChannelsFilter( ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx b/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx index 61a330e..8ba50cc 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.cxx @@ -10,9 +10,6 @@ cpPlugins::BasicFilters::SphereMeshSource:: SphereMeshSource( ) : Superclass( ) { - this->m_ClassName = "cpPlugins::BasicFilters::SphereMeshSource"; - this->m_ClassCategory = "MeshSource"; - this->SetNumberOfInputs( 0 ); this->SetNumberOfOutputs( 1 ); this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.h b/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.h index 6ea0aae..5789134 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.h +++ b/lib/cpPlugins/Plugins/BasicFilters/SphereMeshSource.h @@ -22,6 +22,9 @@ namespace cpPlugins public: itkNewMacro( Self ); itkTypeMacro( SphereMeshSource, cpPluginsInterfaceMeshSource ); + cpPlugins_Id_Macro( + cpPlugins::BasicFilters::SphereMeshSource, "MeshSource" + ); protected: SphereMeshSource( ); diff --git a/lib/cpPlugins/Plugins/IO/ImageReader.cxx b/lib/cpPlugins/Plugins/IO/ImageReader.cxx index fec0944..64bec97 100644 --- a/lib/cpPlugins/Plugins/IO/ImageReader.cxx +++ b/lib/cpPlugins/Plugins/IO/ImageReader.cxx @@ -47,9 +47,6 @@ cpPlugins::IO::ImageReader:: ImageReader( ) : Superclass( ) { - this->m_ClassName = "cpPlugins::IO::ImageReader"; - this->m_ClassCategory = "ImageReader"; - this->SetNumberOfOutputs( 1 ); this->_MakeOutput< cpPlugins::Interface::Image >( 0 ); diff --git a/lib/cpPlugins/Plugins/IO/ImageReader.h b/lib/cpPlugins/Plugins/IO/ImageReader.h index aeee9fa..9793762 100644 --- a/lib/cpPlugins/Plugins/IO/ImageReader.h +++ b/lib/cpPlugins/Plugins/IO/ImageReader.h @@ -33,6 +33,9 @@ namespace cpPlugins public: itkNewMacro( Self ); itkTypeMacro( ImageReader, cpPluginsInterfaceImageSource ); + cpPlugins_Id_Macro( + cpPlugins::IO::ImageReader, "ImageReader" + ); public: virtual bool ExecConfigurationDialog( QWidget* parent ); diff --git a/lib/cpPlugins/Plugins/IO/ImageWriter.cxx b/lib/cpPlugins/Plugins/IO/ImageWriter.cxx index ba94173..c2b9b8a 100644 --- a/lib/cpPlugins/Plugins/IO/ImageWriter.cxx +++ b/lib/cpPlugins/Plugins/IO/ImageWriter.cxx @@ -8,8 +8,6 @@ cpPlugins::IO::ImageWriter:: ImageWriter( ) : Superclass( ) { - this->m_ClassName = "cpPlugins::IO::ImageWriter"; - this->m_ClassCategory = "ImageWriter"; this->SetNumberOfInputs( 1 ); using namespace cpPlugins::Interface; diff --git a/lib/cpPlugins/Plugins/IO/ImageWriter.h b/lib/cpPlugins/Plugins/IO/ImageWriter.h index 9c3b0ce..2d72067 100644 --- a/lib/cpPlugins/Plugins/IO/ImageWriter.h +++ b/lib/cpPlugins/Plugins/IO/ImageWriter.h @@ -22,6 +22,9 @@ namespace cpPlugins public: itkNewMacro( Self ); itkTypeMacro( ImageWriter, cpPluginsInterfaceImageSink ); + cpPlugins_Id_Macro( + cpPlugins::IO::ImageWriter, "ImageWriter" + ); protected: ImageWriter( ); diff --git a/lib/cpPlugins/Plugins/IO/MeshReader.cxx b/lib/cpPlugins/Plugins/IO/MeshReader.cxx index 2585a73..fe61d70 100644 --- a/lib/cpPlugins/Plugins/IO/MeshReader.cxx +++ b/lib/cpPlugins/Plugins/IO/MeshReader.cxx @@ -48,9 +48,6 @@ cpPlugins::IO::MeshReader:: MeshReader( ) : Superclass( ) { - this->m_ClassName = "cpPlugins::IO::MeshReader"; - this->m_ClassCategory = "MeshReader"; - this->SetNumberOfOutputs( 1 ); this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 ); diff --git a/lib/cpPlugins/Plugins/IO/MeshReader.h b/lib/cpPlugins/Plugins/IO/MeshReader.h index 5f721d2..7544a24 100644 --- a/lib/cpPlugins/Plugins/IO/MeshReader.h +++ b/lib/cpPlugins/Plugins/IO/MeshReader.h @@ -24,6 +24,9 @@ namespace cpPlugins public: itkNewMacro( Self ); itkTypeMacro( MeshReader, cpPluginsInterfaceMeshSource ); + cpPlugins_Id_Macro( + cpPlugins::IO::MeshReader, "MeshReader" + ); public: virtual bool ExecConfigurationDialog( QWidget* parent ); diff --git a/lib/cpPlugins/Plugins/IO/MeshWriter.cxx b/lib/cpPlugins/Plugins/IO/MeshWriter.cxx index ee8b666..805ca0e 100644 --- a/lib/cpPlugins/Plugins/IO/MeshWriter.cxx +++ b/lib/cpPlugins/Plugins/IO/MeshWriter.cxx @@ -10,8 +10,6 @@ cpPlugins::IO::MeshWriter:: MeshWriter( ) : Superclass( ) { - this->m_ClassName = "cpPlugins::IO::MeshWriter"; - this->m_ClassCategory = "MeshWriter"; this->SetNumberOfInputs( 1 ); using namespace cpPlugins::Interface; diff --git a/lib/cpPlugins/Plugins/IO/MeshWriter.h b/lib/cpPlugins/Plugins/IO/MeshWriter.h index db13601..9def135 100644 --- a/lib/cpPlugins/Plugins/IO/MeshWriter.h +++ b/lib/cpPlugins/Plugins/IO/MeshWriter.h @@ -24,6 +24,9 @@ namespace cpPlugins public: itkNewMacro( Self ); itkTypeMacro( MeshWriter, cpPluginsInterfaceMeshSink ); + cpPlugins_Id_Macro( + cpPlugins::IO::MeshWriter, "MeshWriter" + ); protected: MeshWriter( ); -- 2.45.2