diff --git a/Core/Code/Interactions/StateMachine.xml b/Core/Code/Interactions/StateMachine.xml
index fd3f3ddaef..163a56a8ac 100644
--- a/Core/Code/Interactions/StateMachine.xml
+++ b/Core/Code/Interactions/StateMachine.xml
@@ -1,3766 +1,3791 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Core/Code/Interactions/mitkDisplayVectorInteractorScroll.cpp b/Core/Code/Interactions/mitkDisplayVectorInteractorScroll.cpp
index f7e266fa44..02c0486003 100644
--- a/Core/Code/Interactions/mitkDisplayVectorInteractorScroll.cpp
+++ b/Core/Code/Interactions/mitkDisplayVectorInteractorScroll.cpp
@@ -1,161 +1,176 @@
/*=========================================================================
Program: Medical Imaging & Interaction Toolkit
Language: C++
Date: $Date: 2010-01-14 14:20:26 +0100 (Thu, 14 Jan 2010) $
Version: $Revision: 21047 $
Copyright (c) German Cancer Research Center, Division of Medical and
Biological Informatics. All rights reserved.
See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "mitkDisplayVectorInteractorScroll.h"
#include "mitkOperation.h"
#include "mitkDisplayCoordinateOperation.h"
//#include "mitkDisplayPositionEvent.h"
#include "mitkUndoController.h"
#include "mitkStateEvent.h"
#include "mitkInteractionConst.h"
#include "mitkAction.h"
void mitk::DisplayVectorInteractorScroll::ExecuteOperation(Operation* itkNotUsed( operation ) )
{
}
bool mitk::DisplayVectorInteractorScroll::ExecuteAction(Action* action, mitk::StateEvent const* stateEvent)
{
bool ok=false;
const DisplayPositionEvent* posEvent=dynamic_cast(stateEvent->GetEvent());
if(posEvent==NULL) return false;
int actionId = action->GetActionId();
switch(actionId)
{
case AcINITMOVE:
{
m_Sender=posEvent->GetSender();
m_StartDisplayCoordinate=posEvent->GetDisplayPosition();
m_LastDisplayCoordinate=posEvent->GetDisplayPosition();
m_CurrentDisplayCoordinate=posEvent->GetDisplayPosition();
ok = true;
break;
}
case AcSCROLL:
{
+ int buttonState = stateEvent->GetEvent()->GetButtonState();
+ if(buttonState == 1025)
+ {
+ m_IsAltModifierActive = true;
+ }
+ else
+ {
+ m_IsAltModifierActive = false;
+ }
mitk::SliceNavigationController::Pointer sliceNaviController = m_Sender->GetSliceNavigationController();
if(sliceNaviController)
{
- this->InvokeEvent( StartInteractionEvent() );
+ this->InvokeEvent( StartScrollInteractionEvent() );
int delta = m_LastDisplayCoordinate[1]-posEvent->GetDisplayPosition()[1];
// if we moved less than 'm_IndexToSliceModifier' pixels slice ONE slice only
if ( delta>0 && delta-m_IndexToSliceModifier)
{
delta=-m_IndexToSliceModifier;
}
delta /= m_IndexToSliceModifier;
if ( m_InvertScrollingDirection )
delta *= -1;
int newPos = sliceNaviController->GetSlice()->GetPos() + delta;
// if auto repeat is on, start at first slice if you reach the last slice and vice versa
int maxSlices = sliceNaviController->GetSlice()->GetSteps();
if ( m_AutoRepeat )
{
while(newPos<0)
{
newPos += maxSlices;
}
while(newPos>=maxSlices)
{
newPos -= maxSlices;
}
}
else
{
// if the new slice is below 0 we still show slice 0
// due to the stepper using unsigned int we have to do this ourselves
if ( newPos < 1 )
newPos = 0;
}
// set the new position
sliceNaviController->GetSlice()->SetPos( newPos );
- this->InvokeEvent( EndInteractionEvent() );
+ this->InvokeEvent( EndScrollInteractionEvent() );
}
m_LastDisplayCoordinate=m_CurrentDisplayCoordinate;
m_CurrentDisplayCoordinate=posEvent->GetDisplayPosition();
}
case AcFINISHMOVE:
{
ok = true;
break;
}
default:
ok = false;
break;
}
return ok;
}
void mitk::DisplayVectorInteractorScroll::SetIndexToSliceModifier( int modifier )
{
m_IndexToSliceModifier = modifier;
}
void mitk::DisplayVectorInteractorScroll::SetAutoRepeat( bool autoRepeat )
{
m_AutoRepeat = autoRepeat;
}
mitk::DisplayVectorInteractorScroll::DisplayVectorInteractorScroll(const char * type, mitk::OperationActor* destination)
: mitk::StateMachine(type)
, m_Sender(NULL)
, m_Destination(destination)
, m_IndexToSliceModifier(4)
, m_AutoRepeat( false )
, m_InvertScrollingDirection( false )
+ , m_IsAltModifierActive( false )
{
m_StartDisplayCoordinate.Fill(0);
m_LastDisplayCoordinate.Fill(0);
m_CurrentDisplayCoordinate.Fill(0);
m_UndoEnabled = false;
//if(m_Destination==NULL)
// m_Destination=this;
}
mitk::DisplayVectorInteractorScroll::~DisplayVectorInteractorScroll()
{
if ( m_Destination != this )
delete m_Destination;
}
void mitk::DisplayVectorInteractorScroll::SetInvertScrollingDirection( bool invert )
{
m_InvertScrollingDirection = invert;
}
+bool mitk::DisplayVectorInteractorScroll::IsAltModifierActive()
+{
+ return m_IsAltModifierActive;
+}
+
diff --git a/Core/Code/Interactions/mitkDisplayVectorInteractorScroll.h b/Core/Code/Interactions/mitkDisplayVectorInteractorScroll.h
index 4332212738..c9b2c977d8 100644
--- a/Core/Code/Interactions/mitkDisplayVectorInteractorScroll.h
+++ b/Core/Code/Interactions/mitkDisplayVectorInteractorScroll.h
@@ -1,118 +1,122 @@
/*=========================================================================
Program: Medical Imaging & Interaction Toolkit
Language: C++
Date: $Date: 2009-05-28 17:19:30 +0200 (Thu, 28 May 2009) $
Version: $Revision: 17495 $
Copyright (c) German Cancer Research Center, Division of Medical and
Biological Informatics. All rights reserved.
See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef MITKDISPLAYVECTORINTERACTORSCROLL_H_HEADER_INCLUDED_C10DC4EB
#define MITKDISPLAYVECTORINTERACTORSCROLL_H_HEADER_INCLUDED_C10DC4EB
#include "mitkCommon.h"
#include "mitkBaseRenderer.h"
#include "mitkStateMachine.h"
namespace mitk {
class Operation;
class OperationActor;
/**
* @brief Interactor for scrolling through the slices of an image
*
* This class implements an Interactor for slice-scrolling. It is defined by the 'Scroll'-statemachine which maps 'initmove' to left mousebutton pressed,
* 'scroll' to left mousebutton and move and 'finishmove' to left mousebutton released.
*
* Thus it is possible to scroll through the slices of an image rapidly, without using the mousewheel.
*
* @ingroup MITK_CORE_EXPORT
**/
class MITK_CORE_EXPORT DisplayVectorInteractorScroll : public StateMachine
{
public:
mitkClassMacro(DisplayVectorInteractorScroll, StateMachine);
mitkNewMacro2Param(Self, const char*, OperationActor*);
itkEventMacro( InteractionEvent, itk::AnyEvent );
- itkEventMacro( StartInteractionEvent, InteractionEvent );
- itkEventMacro( EndInteractionEvent, InteractionEvent );
+ itkEventMacro( StartScrollInteractionEvent, InteractionEvent );
+ itkEventMacro( EndScrollInteractionEvent, InteractionEvent );
/**
* @brief Method derived from OperationActor to recieve and execute operations
**/
virtual void ExecuteOperation(Operation* operation);
/**
* \brief Defines how many slices are scrolled per pixel that the mouse cursor has moved
*/
void SetIndexToSliceModifier( int modifier );
void SetAutoRepeat( bool autoRepeat );
void SetInvertScrollingDirection( bool );
+ bool IsAltModifierActive();
+
protected:
/**
* @brief Default Constructor
**/
DisplayVectorInteractorScroll(const char * type, mitk::OperationActor* destination=NULL);
/**
* @brief Default Destructor
**/
virtual ~DisplayVectorInteractorScroll();
/**
* @brief Method derived from StateMachine to implement the own actions
**/
virtual bool ExecuteAction(Action* action, mitk::StateEvent const* stateEvent);
private:
BaseRenderer::Pointer m_Sender;
mitk::Point2D m_StartDisplayCoordinate;
mitk::Point2D m_LastDisplayCoordinate;
mitk::Point2D m_CurrentDisplayCoordinate;
OperationActor* m_Destination;
/**
* \brief Modifier that defines how many slices are scrolled per pixel that the mouse has moved
*
* This modifier defines how many slices the scene is scrolled per pixel that the mouse cursor has moved.
* By default the modifier is 4. This means that when the user moves the cursor by 4 pixels in Y-direction
* the scene is scrolled by one slice. If the user has moved the the cursor by 20 pixels, the scene is
* scrolled by 5 slices.
*
* If the cursor has moved less than m_IndexToSliceModifier pixels the scene is scrolled by one slice.
*/
int m_IndexToSliceModifier;
/**
* \brief Defines if it is possible to scroll endlessly
*
* If AutoRepeat is on, scrolling further than the last slice will restart at the first slice and vice versa
*/
bool m_AutoRepeat;
bool m_InvertScrollingDirection;
+ bool m_IsAltModifierActive;
+
};
} // namespace mitk
#endif /* MITKDISPLAYVECTORINTERACTOR_H_HEADER_INCLUDED_C10DC4EB */