]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/Interaction/BaseInteractorStyle.cxx
Merge branch 'master' of ssh://git.creatis.insa-lyon.fr/cpPlugins
[cpPlugins.git] / lib / cpExtensions / Interaction / BaseInteractorStyle.cxx
index a384eb0df57c71021b320f60e938a946bed85f74..7cc717886f89fc6a9bfe560fe3eedf8c213164c7 100644 (file)
@@ -18,231 +18,6 @@ SetSetDoubleClickDelay( long delay )
   Self::_TMouseButtonEvent::MaxDoubleClick = delay;
 }
 
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-AddMouseMoveCommand( TMouseCommand command, void* data )
-{
-  if( command != NULL )
-  {
-    this->m_MouseMoveCommands[ command ] = data;
-    this->Modified( );
-
-  } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-AddMouseClickCommand( TMouseCommand command, void* data )
-{
-  if( command != NULL )
-  {
-    this->m_MouseClickCommands[ command ] = data;
-    this->Modified( );
-
-  } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-AddMouseDoubleClickCommand( TMouseCommand command, void* data )
-{
-  if( command != NULL )
-  {
-    this->m_MouseDoubleClickCommands[ command ] = data;
-    this->Modified( );
-
-  } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-AddMouseWheelCommand( TMouseWheelCommand command, void* data )
-{
-  if( command != NULL )
-  {
-    this->m_MouseWheelCommands[ command ] = data;
-    this->Modified( );
-
-  } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-AddKeyCommand( TKeyCommand command, void* data )
-{
-  if( command != NULL )
-  {
-    this->m_KeyCommands[ command ] = data;
-    this->Modified( );
-
-  } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-AddExposeCommand( TVoidCommand command, void* data )
-{
-  if( command != NULL )
-  {
-    this->m_ExposeCommands[ command ] = data;
-    this->Modified( );
-
-  } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-AddConfigureCommand( TVoidCommand command, void* data )
-{
-  if( command != NULL )
-  {
-    this->m_ConfigureCommands[ command ] = data;
-    this->Modified( );
-
-  } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-AddEnterCommand( TVoidCommand command, void* data )
-{
-  if( command != NULL )
-  {
-    this->m_EnterCommands[ command ] = data;
-    this->Modified( );
-
-  } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-AddLeaveCommand( TVoidCommand command, void* data )
-{
-  if( command != NULL )
-  {
-    this->m_LeaveCommands[ command ] = data;
-    this->Modified( );
-
-  } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-RemoveMouseMoveCommand( TMouseCommand command )
-{
-  auto i = this->m_MouseMoveCommands.find( command );
-  if( i != this->m_MouseMoveCommands.end( ) )
-  {
-    this->m_MouseMoveCommands.erase( i );
-    this->Modified( );
-
-  } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-RemoveMouseClickCommand( TMouseCommand command )
-{
-  auto i = this->m_MouseClickCommands.find( command );
-  if( i != this->m_MouseClickCommands.end( ) )
-  {
-    this->m_MouseClickCommands.erase( i );
-    this->Modified( );
-
-  } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-RemoveMouseDoubleClickCommand( TMouseCommand command )
-{
-  auto i = this->m_MouseDoubleClickCommands.find( command );
-  if( i != this->m_MouseDoubleClickCommands.end( ) )
-  {
-    this->m_MouseDoubleClickCommands.erase( i );
-    this->Modified( );
-
-  } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-RemoveMouseWheelCommand( TMouseWheelCommand command )
-{
-  auto i = this->m_MouseWheelCommands.find( command );
-  if( i != this->m_MouseWheelCommands.end( ) )
-  {
-    this->m_MouseWheelCommands.erase( i );
-    this->Modified( );
-
-  } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-RemoveKeyCommand( TKeyCommand command )
-{
-  auto i = this->m_KeyCommands.find( command );
-  if( i != this->m_KeyCommands.end( ) )
-  {
-    this->m_KeyCommands.erase( i );
-    this->Modified( );
-
-  } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-RemoveExposeCommand( TVoidCommand command )
-{
-  auto i = this->m_ExposeCommands.find( command );
-  if( i != this->m_ExposeCommands.end( ) )
-  {
-    this->m_ExposeCommands.erase( i );
-    this->Modified( );
-
-  } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-RemoveConfigureCommand( TVoidCommand command )
-{
-  auto i = this->m_ConfigureCommands.find( command );
-  if( i != this->m_ConfigureCommands.end( ) )
-  {
-    this->m_ConfigureCommands.erase( i );
-    this->Modified( );
-
-  } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-RemoveEnterCommand( TVoidCommand command )
-{
-  auto i = this->m_EnterCommands.find( command );
-  if( i != this->m_EnterCommands.end( ) )
-  {
-    this->m_EnterCommands.erase( i );
-    this->Modified( );
-
-  } // fi
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-RemoveLeaveCommand( TVoidCommand command )
-{
-  auto i = this->m_LeaveCommands.find( command );
-  if( i != this->m_LeaveCommands.end( ) )
-  {
-    this->m_LeaveCommands.erase( i );
-    this->Modified( );
-
-  } // fi
-}
-
 // -------------------------------------------------------------------------
 void cpExtensions::Interaction::BaseInteractorStyle::
 DelegateTDxEvent( unsigned long event, void* calldata )
@@ -451,172 +226,35 @@ OnRightButtonUp( )
 }
 
 // -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-OnLeftClick( )
-{
-  // Get current position on the associated actors
-  vtkRenderWindowInteractor* rwi = this->GetInteractor( );
-  if( rwi == NULL )
-    return;
-
-  // Get mouse pointer position
-  static int idx[ 2 ];
-  static double pos[ 3 ];
-  if( !( this->_PickPosition( idx, pos ) ) )
-    return;
-
-  // Invoke possible events
-  auto i = this->m_MouseClickCommands.begin( );
-  for( ; i != this->m_MouseClickCommands.end( ); ++i )
-    i->first(
-      i->second,
-      Self::ButtonID_Left,
-      idx, pos,
-      rwi->GetAltKey( ) == 1,
-      rwi->GetControlKey( ) == 1,
-      rwi->GetShiftKey( ) == 1
-      );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-OnLeftDoubleClick( )
-{
-  // Get current position on the associated actors
-  vtkRenderWindowInteractor* rwi = this->GetInteractor( );
-  if( rwi == NULL )
-    return;
-
-  // Get mouse pointer position
-  static int idx[ 2 ];
-  static double pos[ 3 ];
-  if( !( this->_PickPosition( idx, pos ) ) )
-    return;
-
-  // Invoke possible events
-  auto i = this->m_MouseDoubleClickCommands.begin( );
-  for( ; i != this->m_MouseDoubleClickCommands.end( ); ++i )
-    i->first(
-      i->second,
-      Self::ButtonID_Left,
-      idx, pos,
-      rwi->GetAltKey( ) == 1,
-      rwi->GetControlKey( ) == 1,
-      rwi->GetShiftKey( ) == 1
-      );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-OnMiddleClick( )
-{
-  // Get current position on the associated actors
-  vtkRenderWindowInteractor* rwi = this->GetInteractor( );
-  if( rwi == NULL )
-    return;
-
-  // Get mouse pointer position
-  static int idx[ 2 ];
-  static double pos[ 3 ];
-  if( !( this->_PickPosition( idx, pos ) ) )
-    return;
-
-  // Invoke possible events
-  auto i = this->m_MouseClickCommands.begin( );
-  for( ; i != this->m_MouseClickCommands.end( ); ++i )
-    i->first(
-      i->second,
-      Self::ButtonID_Middle,
-      idx, pos,
-      rwi->GetAltKey( ) == 1,
-      rwi->GetControlKey( ) == 1,
-      rwi->GetShiftKey( ) == 1
-      );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-OnMiddleDoubleClick( )
-{
-  // Get current position on the associated actors
-  vtkRenderWindowInteractor* rwi = this->GetInteractor( );
-  if( rwi == NULL )
-    return;
-
-  // Get mouse pointer position
-  static int idx[ 2 ];
-  static double pos[ 3 ];
-  if( !( this->_PickPosition( idx, pos ) ) )
-    return;
-
-  // Invoke possible events
-  auto i = this->m_MouseDoubleClickCommands.begin( );
-  for( ; i != this->m_MouseDoubleClickCommands.end( ); ++i )
-    i->first(
-      i->second,
-      Self::ButtonID_Middle,
-      idx, pos,
-      rwi->GetAltKey( ) == 1,
-      rwi->GetControlKey( ) == 1,
-      rwi->GetShiftKey( ) == 1
-      );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-OnRightClick( )
-{
-  // Get current position on the associated actors
-  vtkRenderWindowInteractor* rwi = this->GetInteractor( );
-  if( rwi == NULL )
-    return;
-
-  // Get mouse pointer position
-  static int idx[ 2 ];
-  static double pos[ 3 ];
-  if( !( this->_PickPosition( idx, pos ) ) )
-    return;
-
-  // Invoke possible events
-  auto i = this->m_MouseClickCommands.begin( );
-  for( ; i != this->m_MouseClickCommands.end( ); ++i )
-    i->first(
-      i->second,
-      Self::ButtonID_Right,
-      idx, pos,
-      rwi->GetAltKey( ) == 1,
-      rwi->GetControlKey( ) == 1,
-      rwi->GetShiftKey( ) == 1
-      );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-OnRightDoubleClick( )
-{
-  // Get current position on the associated actors
-  vtkRenderWindowInteractor* rwi = this->GetInteractor( );
-  if( rwi == NULL )
-    return;
-
-  // Get mouse pointer position
-  static int idx[ 2 ];
-  static double pos[ 3 ];
-  if( !( this->_PickPosition( idx, pos ) ) )
-    return;
+#define cpExtensions_BaseInteractorStyle_Click( S, T )          \
+  void cpExtensions::Interaction::BaseInteractorStyle::         \
+  On##S##T( )                                                   \
+  {                                                             \
+    vtkRenderWindowInteractor* rwi = this->GetInteractor( );    \
+    if( rwi == NULL )                                           \
+      return;                                                   \
+    static int idx[ 2 ];                                        \
+    static double pos[ 3 ];                                     \
+    if( !( this->_PickPosition( idx, pos ) ) )                  \
+      return;                                                   \
+    auto i = this->m_Mouse##T##Commands.begin( );               \
+    for( ; i != this->m_Mouse##T##Commands.end( ); ++i )        \
+      i->first(                                                 \
+        i->second,                                              \
+        Self::ButtonID_##S,                                     \
+        idx, pos,                                               \
+        rwi->GetAltKey( ) == 1,                                 \
+        rwi->GetControlKey( ) == 1,                             \
+        rwi->GetShiftKey( ) == 1                                \
+        );                                                      \
+  }
 
-  // Invoke possible events
-  auto i = this->m_MouseDoubleClickCommands.begin( );
-  for( ; i != this->m_MouseDoubleClickCommands.end( ); ++i )
-    i->first(
-      i->second,
-      Self::ButtonID_Right,
-      idx, pos,
-      rwi->GetAltKey( ) == 1,
-      rwi->GetControlKey( ) == 1,
-      rwi->GetShiftKey( ) == 1
-      );
-}
+cpExtensions_BaseInteractorStyle_Click( Left, Click );
+cpExtensions_BaseInteractorStyle_Click( Middle, Click );
+cpExtensions_BaseInteractorStyle_Click( Right, Click );
+cpExtensions_BaseInteractorStyle_Click( Left, DoubleClick );
+cpExtensions_BaseInteractorStyle_Click( Middle, DoubleClick );
+cpExtensions_BaseInteractorStyle_Click( Right, DoubleClick );
 
 // -------------------------------------------------------------------------
 void cpExtensions::Interaction::BaseInteractorStyle::
@@ -633,84 +271,22 @@ OnChar( )
 }
 
 // -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-OnKeyDown( )
-{
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-OnKeyUp( )
-{
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-OnKeyPress( )
-{
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-OnKeyRelease( )
-{
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-OnExpose( )
-{
-  vtkRenderWindowInteractor* rwi = this->GetInteractor( );
-  if( rwi == NULL )
-    return;
-
-  // Invoke possible events
-  auto i = this->m_ExposeCommands.begin( );
-  for( ; i != this->m_ExposeCommands.end( ); ++i )
-    i->first( i->second );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-OnConfigure( )
-{
-  vtkRenderWindowInteractor* rwi = this->GetInteractor( );
-  if( rwi == NULL )
-    return;
-
-  // Invoke possible events
-  auto i = this->m_ConfigureCommands.begin( );
-  for( ; i != this->m_ConfigureCommands.end( ); ++i )
-    i->first( i->second );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-OnEnter( )
-{
-  vtkRenderWindowInteractor* rwi = this->GetInteractor( );
-  if( rwi == NULL )
-    return;
-
-  // Invoke possible events
-  auto i = this->m_EnterCommands.begin( );
-  for( ; i != this->m_EnterCommands.end( ); ++i )
-    i->first( i->second );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Interaction::BaseInteractorStyle::
-OnLeave( )
-{
-  vtkRenderWindowInteractor* rwi = this->GetInteractor( );
-  if( rwi == NULL )
-    return;
+#define cpExtensions_BaseInteractorStyle_Global( N )            \
+  void cpExtensions::Interaction::BaseInteractorStyle::         \
+  On##N( )                                                      \
+  {                                                             \
+    vtkRenderWindowInteractor* rwi = this->GetInteractor( );    \
+    if( rwi == NULL )                                           \
+      return;                                                   \
+    auto i = this->m_##N##Commands.begin( );                    \
+    for( ; i != this->m_##N##Commands.end( ); ++i )             \
+      i->first( i->second );                                    \
+  }
 
-  // Invoke possible events
-  auto i = this->m_LeaveCommands.begin( );
-  for( ; i != this->m_LeaveCommands.end( ); ++i )
-    i->first( i->second );
-}
+cpExtensions_BaseInteractorStyle_Global( Expose );
+cpExtensions_BaseInteractorStyle_Global( Configure );
+cpExtensions_BaseInteractorStyle_Global( Enter );
+cpExtensions_BaseInteractorStyle_Global( Leave );
 
 // -------------------------------------------------------------------------
 void cpExtensions::Interaction::BaseInteractorStyle::