#include <cpPlugins/Extensions/Visualization/ImageInteractorStyle.h>
+#include <ctime>
+
#include <vtkAnnotatedCubeActor.h>
#include <vtkAxesActor.h>
#include <vtkCallbackCommand.h>
// -------------------------------------------------------------------------
const int cpPlugins::Extensions::Visualization::
-ImageInteractorStyle::SliceEvent = vtkCommand::UserEvent + 1;
+ImageInteractorStyle::DoubleClickEvent = vtkCommand::UserEvent + 1;
// -------------------------------------------------------------------------
cpPlugins::Extensions::Visualization::ImageInteractorStyle::
this->OrientationWidget->InteractiveOff( );
}
+// -------------------------------------------------------------------------
+unsigned long cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+AddDoubleClickObserver( vtkCommand* observer )
+{
+ return( this->AddObserver( Self::DoubleClickEvent, observer ) );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+RemoveDoubleClickObserver( unsigned long tag )
+{
+ this->RemoveObserver( tag );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+RemoveDoubleClickObserver( vtkCommand* observer )
+{
+ this->RemoveObserver( observer );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
+RemoveDoubleClickObservers( )
+{
+ this->RemoveObservers( Self::DoubleClickEvent );
+}
+
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
OnMouseMove( )
void cpPlugins::Extensions::Visualization::ImageInteractorStyle::
OnLeftButtonDown( )
{
- int x = this->Interactor->GetEventPosition( )[ 0 ];
- int y = this->Interactor->GetEventPosition( )[ 1 ];
-
- this->FindPokedRenderer( x, y );
+ static double pnt[ 3 ];
+ static int pos[ 2 ];
+ this->Interactor->GetEventPosition( pos );
+ this->FindPokedRenderer( pos[ 0 ], pos[ 1 ] );
if( this->CurrentRenderer == NULL )
return;
this->GrabFocus( this->EventCallbackCommand );
- if( this->Interactor->GetControlKey( ) )
- this->StartCursorMoving( );
-
- /* TODO
- if (!this->Interactor->GetShiftKey() && !this->Interactor->GetControlKey())
- {
- this->WindowLevelStartPosition[0] = x;
- this->WindowLevelStartPosition[1] = y;
- this->StartWindowLevel();
- }
-
- // If shift is held down, do a rotation
- else if (this->InteractionMode == VTKIS_IMAGE3D &&
- this->Interactor->GetShiftKey())
- {
- this->StartRotate();
- }
-
- // If ctrl is held down in slicing mode, slice the image
- else if (this->InteractionMode == VTKIS_IMAGE_SLICING &&
- this->Interactor->GetControlKey())
- {
- this->StartSlice();
- }
-
- // The rest of the button + key combinations remain the same
-
- else
- {
- this->Superclass::OnLeftButtonDown();
- }
- */
+ // TODO: check this code
+ // Manage double-click
+ static const long epsilon_time = 250;
+ static long last_click_time = -( epsilon_time << 1 );
+ long click_time = static_cast< long >( std::clock( ) );
+ if( ( click_time - last_click_time ) < epsilon_time )
+ {
+ last_click_time = -( epsilon_time << 1 );
+ if( this->_PickPosition( pnt ) )
+ this->InvokeEvent( Self::DoubleClickEvent, pnt );
+ }
+ else
+ {
+ last_click_time = click_time;
+ if( this->Interactor->GetControlKey( ) )
+ this->StartCursorMoving( );
+
+ } // fi
}
// -------------------------------------------------------------------------