## = Packages and options =
## ========================
+INCLUDE(CheckCXXCompilerFlag)
+CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
+CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
+IF(COMPILER_SUPPORTS_CXX11)
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+ELSEIF(COMPILER_SUPPORTS_CXX0X)
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+ELSE()
+ MESSAGE(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
+ENDIF()
+
# Prepare header to build shared libs (windows)
INCLUDE(GenerateExportHeader)
SET(
NOPLUGINS_EXAMPLES_PROGRAMS
+ example_BaseInteractorStyle
example_ContourWidget
example_Test_DoubleClick
## example_ExtractDICOMSeries
--- /dev/null
+
+#include <vtkSmartPointer.h>
+
+#include <vtkRenderer.h>
+#include <vtkRenderWindow.h>
+#include <vtkRenderWindowInteractor.h>
+#include <cpExtensions/Visualization/BaseInteractorStyle.h>
+
+int main( int argc, char* argv[] )
+{
+ // 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
+ typedef cpExtensions::Visualization::BaseInteractorStyle TInteractorStyle;
+ vtkSmartPointer< TInteractorStyle > style =
+ vtkSmartPointer< TInteractorStyle >::New( );
+
+ // Set up the interaction
+ vtkSmartPointer< vtkRenderWindowInteractor > interactor =
+ vtkSmartPointer< vtkRenderWindowInteractor >::New( );
+ interactor->SetInteractorStyle( style );
+ window->SetInteractor( interactor );
+
+ // Begin interaction
+ window->Render( );
+ interactor->Start( );
+
+ return( 0 );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#include <cpExtensions/Visualization/BaseInteractorStyle.h>
+
+/*
+ Compile ITK and VTK with: cmake -DCMAKE_CXX_FLAGS="-std=c++11" /dir/to/source
+*/
+/*
+ typedef std::chrono::time_point< std::chrono::system_clock > TTime;
+ typedef std::chrono::duration< long, std::ratio< 1, 1000 > > TTimeDiff;
+*/
+
+#include <chrono>
+
+#include <vtkCallbackCommand.h>
+
+// -------------------------------------------------------------------------
+/*
+ const cpExtensions::Visualization::BaseInteractorStyle::TTime
+ cpExtensions::Visualization::BaseInteractorStyle::MinTime =
+ cpExtensions::Visualization::BaseInteractorStyle::TTime::min( );
+*/
+
+// -------------------------------------------------------------------------
+cpExtensions::Visualization::BaseInteractorStyle::
+Self* cpExtensions::Visualization::BaseInteractorStyle::
+New( )
+{
+ return( new Self );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::BaseInteractorStyle::
+DelegateTDxEvent( unsigned long event, void* calldata )
+{
+ // TODO
+}
+
+// -------------------------------------------------------------------------
+cpExtensions::Visualization::BaseInteractorStyle::
+BaseInteractorStyle( )
+ : Superclass( )
+{
+ this->LastButton = Self::ButtonID_None;
+ this->LastButtonUp = 0;
+ this->LastButtonHeld = 0;
+ this->LastButtonDown = -1;
+ this->EventCallbackCommand->SetCallback( Self::_ProcessEvents );
+}
+
+// -------------------------------------------------------------------------
+cpExtensions::Visualization::BaseInteractorStyle::
+~BaseInteractorStyle( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::BaseInteractorStyle::
+_ProcessEvents(
+ vtkObject* object,
+ unsigned long event,
+ void* clientdata,
+ void* calldata
+ )
+{
+ // Get active style
+ Self* s = reinterpret_cast< Self* >( clientdata );
+ if( s == NULL )
+ return;
+
+ // Process events
+ switch( event )
+ {
+ case vtkCommand::MouseMoveEvent:
+ {
+ if( s->HandleObservers && s->HasObserver( vtkCommand::MouseMoveEvent ) )
+ s->InvokeEvent( vtkCommand::MouseMoveEvent, NULL );
+ else
+ s->OnMouseMove( );
+ }
+ break;
+ case vtkCommand::LeftButtonPressEvent:
+ {
+ /*
+ 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++;
+ */
+ }
+ break;
+ case vtkCommand::LeftButtonReleaseEvent:
+ {
+ long count =
+ std::chrono::duration_cast< std::chrono::milliseconds >(
+ std::chrono::system_clock::now( )
+ ).count( );
+ s->LastButtonUp = count;
+ s->LastButtonHeld = 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
+ */
+ }
+ break;
+ case vtkCommand::MiddleButtonPressEvent:
+ {
+ }
+ break;
+ case vtkCommand::MiddleButtonReleaseEvent:
+ {
+ }
+ break;
+ case vtkCommand::RightButtonPressEvent:
+ {
+ }
+ break;
+ case vtkCommand::RightButtonReleaseEvent:
+ {
+ }
+ break;
+ case vtkCommand::MouseWheelForwardEvent:
+ {
+ if( s->HandleObservers && s->HasObserver( vtkCommand::MouseWheelForwardEvent ) )
+ s->InvokeEvent( vtkCommand::MouseWheelForwardEvent, NULL );
+ else
+ s->OnMouseWheelForward( );
+ }
+ break;
+ case vtkCommand::MouseWheelBackwardEvent:
+ {
+ if( s->HandleObservers && s->HasObserver( vtkCommand::MouseWheelBackwardEvent ) )
+ s->InvokeEvent( vtkCommand::MouseWheelBackwardEvent, NULL );
+ else
+ s->OnMouseWheelBackward( );
+ }
+ break;
+ case vtkCommand::KeyPressEvent:
+ {
+ if( s->HandleObservers && s->HasObserver( vtkCommand::KeyPressEvent ) )
+ s->InvokeEvent( vtkCommand::KeyPressEvent, NULL );
+ else
+ {
+ s->OnKeyDown( );
+ s->OnKeyPress( );
+
+ } // fi
+ }
+ break;
+ case vtkCommand::KeyReleaseEvent:
+ {
+ if( s->HandleObservers && s->HasObserver( vtkCommand::KeyReleaseEvent ) )
+ s->InvokeEvent( vtkCommand::KeyReleaseEvent, NULL );
+ else
+ {
+ s->OnKeyUp( );
+ s->OnKeyRelease( );
+
+ } // fi
+ }
+ break;
+ case vtkCommand::CharEvent:
+ {
+ if( s->HandleObservers && s->HasObserver( vtkCommand::CharEvent ) )
+ s->InvokeEvent( vtkCommand::CharEvent, NULL );
+ else
+ s->OnChar( );
+ }
+ break;
+ case vtkCommand::ExposeEvent:
+ {
+ if( s->HandleObservers && s->HasObserver( vtkCommand::ExposeEvent ) )
+ s->InvokeEvent( vtkCommand::ExposeEvent, NULL );
+ else
+ s->OnExpose( );
+ }
+ break;
+ case vtkCommand::ConfigureEvent:
+ {
+ if( s->HandleObservers && s->HasObserver( vtkCommand::ConfigureEvent ) )
+ s->InvokeEvent( vtkCommand::ConfigureEvent, NULL );
+ else
+ s->OnConfigure( );
+ }
+ break;
+ case vtkCommand::EnterEvent:
+ {
+ if( s->HandleObservers && s->HasObserver( vtkCommand::EnterEvent ) )
+ s->InvokeEvent( vtkCommand::EnterEvent, NULL );
+ else
+ s->OnEnter( );
+ }
+ break;
+ case vtkCommand::LeaveEvent:
+ {
+ if( s->HandleObservers && s->HasObserver( vtkCommand::LeaveEvent ) )
+ s->InvokeEvent( vtkCommand::LeaveEvent, NULL );
+ else
+ s->OnLeave( );
+ }
+ break;
+ case vtkCommand::TimerEvent:
+ {
+ // Do nothing
+ }
+ break;
+ case vtkCommand::DeleteEvent:
+ {
+ s->SetInteractor( 0 );
+ }
+ break;
+ case vtkCommand::TDxMotionEvent:
+ case vtkCommand::TDxButtonPressEvent:
+ case vtkCommand::TDxButtonReleaseEvent:
+ {
+ s->DelegateTDxEvent( event, calldata );
+ }
+ break;
+ default:
+ break;
+ } // hctiws
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPEXTENSIONS__VISUALIZATION__BASEINTERACTORSTYLE__H__
+#define __CPEXTENSIONS__VISUALIZATION__BASEINTERACTORSTYLE__H__
+
+#include <cpExtensions/cpExtensions_Export.h>
+
+#include <vtkInteractorStyle.h>
+
+namespace cpExtensions
+{
+ namespace Visualization
+ {
+ /**
+ */
+ class cpExtensions_EXPORT BaseInteractorStyle
+ : public vtkInteractorStyle
+ {
+ public:
+ typedef BaseInteractorStyle Self;
+ vtkTypeMacro( BaseInteractorStyle, vtkInteractorStyle );
+
+ enum ButtonID
+ {
+ ButtonID_None = 0x00,
+ ButtonID_Left = 0x01,
+ ButtonID_Middle = 0x02,
+ ButtonID_Right = 0x03
+ };
+
+ public:
+ static Self* New( );
+
+ void DelegateTDxEvent( unsigned long event, void* calldata );
+
+ // Possible mouse motion events
+ virtual void OnMouseMove( ) { }
+ virtual void OnMouseWheelForward( ) { }
+ virtual void OnMouseWheelBackward( ) { }
+
+ // Possible mouse click-related events
+ virtual void OnLeftButtonDown( ) { }
+ virtual void OnLeftButtonUp( ) { }
+ virtual void OnLeftClick( ) { }
+ virtual void OnLeftDoubleClick( ) { }
+ virtual void OnMiddleButtonDown( ) { }
+ virtual void OnMiddleButtonUp( ) { }
+ virtual void OnMiddleClick( ) { }
+ virtual void OnMiddleDoubleClick( ) { }
+ virtual void OnRightButtonDown( ) { }
+ virtual void OnRightButtonUp( ) { }
+ virtual void OnRightClick( ) { }
+ virtual void OnRightDoubleClick( ) { }
+
+ // Keyboard-related events
+ virtual void OnChar( ) { }
+ virtual void OnKeyDown( ) { }
+ virtual void OnKeyUp( ) { }
+ virtual void OnKeyPress( ) { }
+ virtual void OnKeyRelease( ) { }
+
+ // Other events
+ virtual void OnExpose( ) { }
+ virtual void OnConfigure( ) { }
+ virtual void OnEnter( ) { }
+ virtual void OnLeave( ) { }
+
+ // Unused methods
+ inline void StartState( int newstate ) { }
+ inline void StopState( ) { }
+ inline void StartAnimate( ) { }
+ inline void StopAnimate( ) { }
+ inline void StartRotate( ) { }
+ inline void EndRotate( ) { }
+ inline void StartZoom( ) { }
+ inline void EndZoom( ) { }
+ inline void StartPan( ) { }
+ inline void EndPan( ) { }
+ inline void StartSpin( ) { }
+ inline void EndSpin( ) { }
+ inline void StartDolly( ) { }
+ inline void EndDolly( ) { }
+ inline void StartUniformScale( ) { }
+ inline void EndUniformScale( ) { }
+ inline void StartTimer( ) { }
+ inline void EndTimer( ) { }
+ inline void StartTwoPointer( ) { }
+ inline void EndTwoPointer( ) { }
+ inline void OnTimer( ) { }
+
+ protected:
+ BaseInteractorStyle( );
+ virtual ~BaseInteractorStyle( );
+
+ static void _ProcessEvents(
+ vtkObject* object,
+ unsigned long event,
+ void* clientdata,
+ void* calldata
+ );
+
+ private:
+ // Purposely not implemented
+ BaseInteractorStyle( const Self& );
+ Self& operator=( const Self& );
+
+ protected:
+ ButtonID LastButton;
+ long LastButtonUp;
+ long LastButtonHeld;
+ long LastButtonDown;
+ };
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // __CPEXTENSIONS__VISUALIZATION__BASEINTERACTORSTYLE__H__
+
+// eof - $RCSfile$
#include <complex>
+#undef ITK_MANUAL_INSTANTIATION
#include <itkImage.h>
#include <itkImageToVTKImageFilter.h>
Object( )
: Superclass( )
{
- this->m_ClassName = "cpPlugins::Interface::Object";
- this->m_ClassCategory = "BasicObject";
}
// -------------------------------------------------------------------------
} \
};
+// -------------------------------------------------------------------------
+#define cpPlugins_Id_Macro( name, category ) \
+ public: \
+ static std::string GetClassName( ) { return( #name ); } \
+ static std::string GetClassCategory( ) { return( category ); }
+
namespace cpPlugins
{
namespace Interface
public:
itkNewMacro( Self );
itkTypeMacro( Object, itkObject );
+ cpPlugins_Id_Macro( cpPlugins::Interface::Object, "BaseObject" );
- public:
- itkGetConstMacro( ClassName, std::string );
- itkGetConstMacro( ClassCategory, std::string );
+ itkGetStringMacro( Name );
+ itkSetStringMacro( Name );
protected:
Object( );
Self& operator=( const Self& );
protected:
- std::string m_ClassName;
- std::string m_ClassCategory;
+ std::string m_Name;
};
/**