example_TestParameters
example_LoadPlugins
example_ReadWriteImage
+ example_View2DImage
##example_MarchingCubes
##example_OtsuFilter
##example_RGBImageToHSVChannels
NOPLUGINS_EXAMPLES_PROGRAMS
example_BaseInteractorStyle
example_ContourWidget
- example_Test_DoubleClick
+ ## example_Test_DoubleClick
## example_ExtractDICOMSeries
## example_ImageGaussianModelEstimator
## example_ReadQuadEdgeMeshWithoutPlugins
#include <vtkRenderWindowInteractor.h>
#include <cpExtensions/Visualization/BaseInteractorStyle.h>
+// -------------------------------------------------------------------------
+#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
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 =
--- /dev/null
+#include <cstdlib>
+#include <iostream>
+#include <string>
+
+#include <vtkRenderer.h>
+#include <vtkRenderWindow.h>
+#include <vtkRenderWindowInteractor.h>
+
+#include <cpPlugins/Interface/Interface.h>
+#include <cpPlugins/Interface/ProcessObject.h>
+#include <cpPlugins/Interface/Image.h>
+
+#include <cpExtensions/Visualization/ImageSliceActors.h>
+
+// -------------------------------------------------------------------------
+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$
#include <cpExtensions/Visualization/BaseInteractorStyle.h>
-/* =========================================================================
- * 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 <chrono>
#include <vtkCallbackCommand.h>
// -------------------------------------------------------------------------
-const long cpExtensions::Visualization::BaseInteractorStyle::
-MAX_DOUBLE_CLICK = 200;
+const long cpExtensions::Visualization::BaseInteractorStyle::MouseButtonEvent::
+MAX_DOUBLE_CLICK = 200; // ms
// -------------------------------------------------------------------------
cpExtensions::Visualization::BaseInteractorStyle::
DelegateTDxEvent( unsigned long event, void* calldata )
{
// TODO
+ std::cerr << "No TDx support at this time!" << std::endl;
+ std::exit( 1 );
}
// -------------------------------------------------------------------------
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 );
}
void* calldata
)
{
- // Get active style
+ // Get active style and interactor
Self* s = reinterpret_cast< Self* >( clientdata );
if( s == NULL )
return;
{
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:
#include <cpExtensions/cpExtensions_Export.h>
+#include <chrono>
#include <vtkInteractorStyle.h>
+/*
+ * 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
enum ButtonID
{
- ButtonID_None = 0x00,
- ButtonID_Left = 0x01,
- ButtonID_Middle = 0x02,
- ButtonID_Right = 0x03
+ ButtonID_None = 0,
+ ButtonID_Left,
+ ButtonID_Middle,
+ ButtonID_Right
};
public:
virtual void OnMouseWheelBackward( ) { }
// Possible mouse click-related events
+ inline ButtonID GetButtonID( ) const
+ { return( this->ActiveButton ); }
virtual void OnLeftButtonDown( ) { }
virtual void OnLeftButtonUp( ) { }
virtual void OnLeftClick( ) { }
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
#include <cpExtensions/Visualization/ImageInteractorStyle.h>
+#include <vtkImageActor.h>
+#include <vtkRenderWindowInteractor.h>
+
+// -------------------------------------------------------------------------
+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 <cmath>
#include <ctime>
this->Interactor->Render( );
}
+*/
// eof - $RCSfile$
#ifndef __CPEXTENSIONS__VISUALIZATION__IMAGEINTERACTORSTYLE__H__
#define __CPEXTENSIONS__VISUALIZATION__IMAGEINTERACTORSTYLE__H__
-#include <vector>
+#include <cpExtensions/Visualization/BaseInteractorStyle.h>
-#include <vtkInteractorStyleImage.h>
-#include <vtkOrientationMarkerWidget.h>
-#include <vtkPropPicker.h>
#include <vtkSmartPointer.h>
+#include <vtkPropPicker.h>
+
+/* TODO
+ #include <vector>
+
+ #include <vtkInteractorStyleImage.h>
+ #include <vtkOrientationMarkerWidget.h>
-#include <cpExtensions/cpExtensions_Export.h>
+ #include <cpExtensions/cpExtensions_Export.h>
-// -------------------------------------------------------------------------
-#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
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;
vtkSmartPointer< vtkPolyDataMapper > CircleMapper;
vtkSmartPointer< vtkActor > CircleActor;
- public:
+ public:
static const int CursorEvent;
static const int RadiusEvent;
static const int DoubleClickEvent;
- };
+ };
+ */
} // ecapseman
#include <cpExtensions/Visualization/ImageSliceActors.h>
+#include <sstream>
+
#include <vtkAlgorithmOutput.h>
#include <vtkCellArray.h>
#include <vtkImageData.h>
#include <vtkPlane.h>
#include <vtkPoints.h>
#include <vtkProperty.h>
+#include <vtkRenderer.h>
#include <vtkStreamingDemandDrivenPipeline.h>
#include <vtkTextProperty.h>
// Delete all images
this->SliceMappers.clear( );
this->ImageActors.clear( );
- this->OtherActors.clear( );
+ this->AssociatedActors.clear( );
// Reconfigure unique objects
this->PlaneFunction = vtkSmartPointer< vtkPlane >::New( );
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
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 );
}
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( );
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 )
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( );
}
{
this->AddItem( this->TextActor );
this->AddItem( this->PlaneActor );
+ this->Style->AssociateImageActor( actor );
} // fi
this->AddItem( actor );
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$
#include <vtkSmartPointer.h>
#include <vtkTextActor.h>
+#include <cpExtensions/Visualization/ImageInteractorStyle.h>
+
// -------------------------------------------------------------------------
class vtkAlgorithmOutput;
class vtkImageData;
public:
typedef ImageSliceActors Self;
- typedef void ( *TUpdateCommand )( void* );
-
public:
vtkTypeMacro( ImageSliceActors, vtkPropCollection );
// 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;
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;
char TextBuffer[ 1024 ];
vtkSmartPointer< vtkTextActor > TextActor;
vtkSmartPointer< vtkActor > PlaneActor;
-
-
- TUpdateCommand m_UpdateCommand;
- void* m_UpdateData;
};
} // ecapseman
// 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
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
{
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
#include <cpExtensions/cpExtensions_Export.h>
#include <cpExtensions/Visualization/MPRActors.h>
-#include <cpExtensions/Visualization/ImageInteractorStyle.h>
#include <vtkObject.h>
#include <vtkRenderer.h>
{
public:
typedef MPRObjects Self;
- typedef cpExtensions::Visualization::MPRActors TMPRActors;
- typedef cpExtensions::Visualization::ImageInteractorStyle TStyle;
+ typedef cpExtensions::Visualization::MPRActors TMPRActors;
public:
vtkTypeMacro( MPRObjects, vtkObject );
// Internal pipelines
vtkSmartPointer< TMPRActors > m_MPRActors;
vtkSmartPointer< vtkRenderer > m_Renderers[ 4 ];
- vtkSmartPointer< TStyle > m_Styles[ 3 ];
};
} // ecapseman
#include <cpPlugins/Interface/ProcessObject.h>
// -------------------------------------------------------------------------
-#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( ) { }
// -------------------------------------------------------------------------
m_VTKObject( NULL ),
m_Source( NULL )
{
- this->m_ClassName = "cpPlugins::Interface::DataObject";
- this->m_ClassCategory = "BasicObject";
}
// -------------------------------------------------------------------------
public:
itkTypeMacro( DataObject, Object );
+ cpPlugins_Id_Macro(
+ cpPlugins::Interface::DataObject, "BasicObject"
+ );
public:
Object* GetSource( );
Image( )
: Superclass( )
{
- this->m_ClassName = "cpPlugins::Interface::Image";
- this->m_ClassCategory = "BasicObject";
}
// -------------------------------------------------------------------------
public:
itkNewMacro( Self );
itkTypeMacro( Image, DataObject );
+ cpPlugins_Id_Macro(
+ cpPlugins::Interface::Image, "DataObject"
+ );
public:
template< class I >
m_Mapper( NULL ),
m_Actor( NULL )
{
- this->m_ClassName = "cpPlugins::Interface::Mesh";
- this->m_ClassCategory = "BasicObject";
}
// -------------------------------------------------------------------------
public:
itkNewMacro( Self );
itkTypeMacro( Mesh, DataObject );
+ cpPlugins_Id_Macro(
+ cpPlugins::Interface::Mesh, "DataObject"
+ );
public:
template< class M >
// -------------------------------------------------------------------------
#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
{
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 )
m_ITKObject( NULL ),
m_VTKObject( NULL )
{
- this->m_ClassName = "cpPlugins::Interface::ProcessObject";
- this->m_ClassCategory = "BasicObject";
}
// -------------------------------------------------------------------------
public:
itkTypeMacro( ProcessObject, Object );
+ cpPlugins_Id_Macro(
+ cpPlugins::Interface::ProcessObject, "BaseObject"
+ );
public:
virtual const Parameters& GetDefaultParameters( ) const;
BinaryThresholdImageFilter( )
: Superclass( )
{
- this->m_ClassName = "cpPlugins::BasicFilters::BinaryThresholdImageFilter";
- this->m_ClassCategory = "ImageToImageFilter";
this->SetNumberOfInputs( 1 );
this->SetNumberOfOutputs( 1 );
this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
BinaryThresholdImageFilter,
cpPluginsInterfaceImageToImageFilter
);
+ cpPlugins_Id_Macro(
+ cpPlugins::BasicFilters::BinaryThresholdImageFilter,
+ "ImageToImageFilter"
+ );
protected:
BinaryThresholdImageFilter( );
Cutter( )
: Superclass( )
{
- this->m_ClassName = "cpPlugins::BasicFilters::Cutter";
- this->m_ClassCategory = "MeshToMeshFilter";
-
this->SetNumberOfInputs( 2 );
this->SetNumberOfOutputs( 1 );
this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
public:
itkNewMacro( Self );
itkTypeMacro( Cutter, cpPluginsInterfaceMeshToMeshFilter );
+ cpPlugins_Id_Macro(
+ cpPlugins::BasicFilters::Cutter,
+ "MeshToMeshFilter"
+ );
protected:
Cutter( );
ExtractSliceImageFilter( )
: Superclass( )
{
- this->m_ClassName = "cpPlugins::BasicFilters::ExtractSliceImageFilter";
- this->m_ClassCategory = "ImageToImageFilter";
this->SetNumberOfInputs( 1 );
this->SetNumberOfOutputs( 1 );
this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
itkTypeMacro(
ExtractSliceImageFilter, cpPluginsInterfaceImageToImageFilter
);
+ cpPlugins_Id_Macro(
+ cpPlugins::BasicFilters::ExtractSliceImageFilter,
+ "ImageToImageFilter"
+ );
protected:
ExtractSliceImageFilter( );
MarchingCubes( )
: Superclass( )
{
- this->m_ClassName = "cpPlugins::BasicFilters::MarchingCubes";
- this->m_ClassCategory = "ImageToMeshFilter";
-
this->SetNumberOfInputs( 1 );
this->SetNumberOfOutputs( 1 );
this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
public:
itkNewMacro( Self );
itkTypeMacro( MarchingCubes, cpPluginsInterfaceImageToMeshFilter );
+ cpPlugins_Id_Macro(
+ cpPlugins::BasicFilters::MarchingCubes, "ImageToMeshFilter"
+ );
protected:
MarchingCubes( );
MedianImageFilter( )
: Superclass( )
{
- this->m_ClassName = "cpPlugins::BasicFilters::MedianImageFilter";
- this->m_ClassCategory = "ImageToImageFilter";
this->SetNumberOfInputs( 1 );
this->SetNumberOfOutputs( 1 );
this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
MedianImageFilter,
cpPluginsInterfaceImageToImageFilter
);
+ cpPlugins_Id_Macro(
+ cpPlugins::BasicFilters::MedianImageFilter,
+ "ImageToImageFilter"
+ );
protected:
MedianImageFilter( );
OtsuThresholdImageFilter( )
: Superclass( )
{
- this->m_ClassName = "cpPlugins::BasicFilters::OtsuThresholdImageFilter";
- this->m_ClassCategory = "ImageToImageFilter";
this->SetNumberOfInputs( 1 );
this->SetNumberOfOutputs( 1 );
this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
OtsuThresholdImageFilter,
cpPluginsInterfaceImageToImageFilter
);
+ cpPlugins_Id_Macro(
+ cpPlugins::BasicFilters::OtsuThresholdImageFilter,
+ "ImageToImageFilter"
+ );
protected:
OtsuThresholdImageFilter( );
{
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 );
RGBImageToOtherChannelsFilter,
cpPluginsInterfaceImageToImageFilter
);
+ cpPlugins_Id_Macro(
+ cpPlugins::BasicFilters::RGBImageToOtherChannelsFilter,
+ "ImageToImageFilter"
+ );
protected:
RGBImageToOtherChannelsFilter( );
SphereMeshSource( )
: Superclass( )
{
- this->m_ClassName = "cpPlugins::BasicFilters::SphereMeshSource";
- this->m_ClassCategory = "MeshSource";
-
this->SetNumberOfInputs( 0 );
this->SetNumberOfOutputs( 1 );
this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
public:
itkNewMacro( Self );
itkTypeMacro( SphereMeshSource, cpPluginsInterfaceMeshSource );
+ cpPlugins_Id_Macro(
+ cpPlugins::BasicFilters::SphereMeshSource, "MeshSource"
+ );
protected:
SphereMeshSource( );
ImageReader( )
: Superclass( )
{
- this->m_ClassName = "cpPlugins::IO::ImageReader";
- this->m_ClassCategory = "ImageReader";
-
this->SetNumberOfOutputs( 1 );
this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
public:
itkNewMacro( Self );
itkTypeMacro( ImageReader, cpPluginsInterfaceImageSource );
+ cpPlugins_Id_Macro(
+ cpPlugins::IO::ImageReader, "ImageReader"
+ );
public:
virtual bool ExecConfigurationDialog( QWidget* parent );
ImageWriter( )
: Superclass( )
{
- this->m_ClassName = "cpPlugins::IO::ImageWriter";
- this->m_ClassCategory = "ImageWriter";
this->SetNumberOfInputs( 1 );
using namespace cpPlugins::Interface;
public:
itkNewMacro( Self );
itkTypeMacro( ImageWriter, cpPluginsInterfaceImageSink );
+ cpPlugins_Id_Macro(
+ cpPlugins::IO::ImageWriter, "ImageWriter"
+ );
protected:
ImageWriter( );
MeshReader( )
: Superclass( )
{
- this->m_ClassName = "cpPlugins::IO::MeshReader";
- this->m_ClassCategory = "MeshReader";
-
this->SetNumberOfOutputs( 1 );
this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
public:
itkNewMacro( Self );
itkTypeMacro( MeshReader, cpPluginsInterfaceMeshSource );
+ cpPlugins_Id_Macro(
+ cpPlugins::IO::MeshReader, "MeshReader"
+ );
public:
virtual bool ExecConfigurationDialog( QWidget* parent );
MeshWriter( )
: Superclass( )
{
- this->m_ClassName = "cpPlugins::IO::MeshWriter";
- this->m_ClassCategory = "MeshWriter";
this->SetNumberOfInputs( 1 );
using namespace cpPlugins::Interface;
public:
itkNewMacro( Self );
itkTypeMacro( MeshWriter, cpPluginsInterfaceMeshSink );
+ cpPlugins_Id_Macro(
+ cpPlugins::IO::MeshWriter, "MeshWriter"
+ );
protected:
MeshWriter( );