diff --git a/Modules/Core/files.cmake b/Modules/Core/files.cmake index bd87026474..c7323502f0 100644 --- a/Modules/Core/files.cmake +++ b/Modules/Core/files.cmake @@ -1,315 +1,316 @@ file(GLOB_RECURSE H_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include/*") set(CPP_FILES mitkCoreActivator.cpp mitkCoreObjectFactoryBase.cpp mitkCoreObjectFactory.cpp mitkCoreServices.cpp mitkException.cpp Algorithms/mitkBaseDataSource.cpp Algorithms/mitkClippedSurfaceBoundsCalculator.cpp Algorithms/mitkCompareImageDataFilter.cpp Algorithms/mitkCompositePixelValueToString.cpp Algorithms/mitkConvert2Dto3DImageFilter.cpp Algorithms/mitkDataNodeSource.cpp Algorithms/mitkExtractSliceFilter.cpp Algorithms/mitkHistogramGenerator.cpp Algorithms/mitkImageChannelSelector.cpp Algorithms/mitkImageSliceSelector.cpp Algorithms/mitkImageSource.cpp Algorithms/mitkImageTimeSelector.cpp Algorithms/mitkImageToImageFilter.cpp Algorithms/mitkImageToSurfaceFilter.cpp Algorithms/mitkMultiComponentImageDataComparisonFilter.cpp Algorithms/mitkPlaneGeometryDataToSurfaceFilter.cpp Algorithms/mitkPointSetSource.cpp Algorithms/mitkPointSetToPointSetFilter.cpp Algorithms/mitkRGBToRGBACastImageFilter.cpp Algorithms/mitkSubImageSelector.cpp Algorithms/mitkSurfaceSource.cpp Algorithms/mitkSurfaceToImageFilter.cpp Algorithms/mitkSurfaceToSurfaceFilter.cpp Algorithms/mitkUIDGenerator.cpp Algorithms/mitkVolumeCalculator.cpp Controllers/mitkBaseController.cpp Controllers/mitkCallbackFromGUIThread.cpp Controllers/mitkCameraController.cpp Controllers/mitkCameraRotationController.cpp Controllers/mitkLimitedLinearUndo.cpp Controllers/mitkOperationEvent.cpp Controllers/mitkPlanePositionManager.cpp Controllers/mitkProgressBar.cpp Controllers/mitkRenderingManager.cpp Controllers/mitkSliceNavigationController.cpp Controllers/mitkSlicesCoordinator.cpp Controllers/mitkStatusBar.cpp Controllers/mitkStepper.cpp Controllers/mitkTestManager.cpp Controllers/mitkUndoController.cpp Controllers/mitkVerboseLimitedLinearUndo.cpp Controllers/mitkVtkLayerController.cpp DataManagement/mitkAnatomicalStructureColorPresets.cpp DataManagement/mitkArbitraryTimeGeometry.cpp DataManagement/mitkAbstractTransformGeometry.cpp DataManagement/mitkAnnotationProperty.cpp DataManagement/mitkApplicationCursor.cpp DataManagement/mitkApplyTransformMatrixOperation.cpp DataManagement/mitkBaseData.cpp DataManagement/mitkBaseGeometry.cpp DataManagement/mitkBaseProperty.cpp DataManagement/mitkChannelDescriptor.cpp DataManagement/mitkClippingProperty.cpp DataManagement/mitkColorProperty.cpp DataManagement/mitkDataNode.cpp DataManagement/mitkDataStorage.cpp DataManagement/mitkEnumerationProperty.cpp DataManagement/mitkFloatPropertyExtension.cpp DataManagement/mitkGeometry3D.cpp DataManagement/mitkGeometryData.cpp DataManagement/mitkGeometryTransformHolder.cpp DataManagement/mitkGroupTagProperty.cpp DataManagement/mitkImageAccessorBase.cpp DataManagement/mitkImageCaster.cpp DataManagement/mitkImageCastPart1.cpp DataManagement/mitkImageCastPart2.cpp DataManagement/mitkImageCastPart3.cpp DataManagement/mitkImageCastPart4.cpp DataManagement/mitkImage.cpp DataManagement/mitkImageDataItem.cpp DataManagement/mitkImageDescriptor.cpp DataManagement/mitkImageReadAccessor.cpp DataManagement/mitkImageStatisticsHolder.cpp DataManagement/mitkImageVtkAccessor.cpp DataManagement/mitkImageVtkReadAccessor.cpp DataManagement/mitkImageVtkWriteAccessor.cpp DataManagement/mitkImageWriteAccessor.cpp DataManagement/mitkIntPropertyExtension.cpp DataManagement/mitkIPersistenceService.cpp DataManagement/mitkIPropertyAliases.cpp DataManagement/mitkIPropertyDescriptions.cpp DataManagement/mitkIPropertyExtensions.cpp DataManagement/mitkIPropertyFilters.cpp DataManagement/mitkIPropertyPersistence.cpp DataManagement/mitkLandmarkProjectorBasedCurvedGeometry.cpp DataManagement/mitkLandmarkProjector.cpp DataManagement/mitkLevelWindow.cpp DataManagement/mitkLevelWindowManager.cpp DataManagement/mitkLevelWindowPreset.cpp DataManagement/mitkLevelWindowProperty.cpp DataManagement/mitkLine.cpp DataManagement/mitkLookupTable.cpp DataManagement/mitkLookupTableProperty.cpp DataManagement/mitkLookupTables.cpp # specializations of GenericLookupTable DataManagement/mitkMaterial.cpp DataManagement/mitkMemoryUtilities.cpp DataManagement/mitkModalityProperty.cpp DataManagement/mitkModifiedLock.cpp DataManagement/mitkNodePredicateAnd.cpp DataManagement/mitkNodePredicateBase.cpp DataManagement/mitkNodePredicateCompositeBase.cpp DataManagement/mitkNodePredicateData.cpp DataManagement/mitkNodePredicateDataType.cpp DataManagement/mitkNodePredicateDimension.cpp DataManagement/mitkNodePredicateFirstLevel.cpp DataManagement/mitkNodePredicateGeometry.cpp DataManagement/mitkNodePredicateNot.cpp DataManagement/mitkNodePredicateOr.cpp DataManagement/mitkNodePredicateProperty.cpp DataManagement/mitkNodePredicateDataProperty.cpp DataManagement/mitkNodePredicateSource.cpp DataManagement/mitkNumericConstants.cpp DataManagement/mitkPlaneGeometry.cpp DataManagement/mitkPlaneGeometryData.cpp DataManagement/mitkPlaneOperation.cpp DataManagement/mitkPlaneOrientationProperty.cpp DataManagement/mitkPointOperation.cpp DataManagement/mitkPointSet.cpp DataManagement/mitkPointSetShapeProperty.cpp DataManagement/mitkProperties.cpp DataManagement/mitkPropertyAliases.cpp DataManagement/mitkPropertyDescriptions.cpp DataManagement/mitkPropertyExtension.cpp DataManagement/mitkPropertyExtensions.cpp DataManagement/mitkPropertyFilter.cpp DataManagement/mitkPropertyFilters.cpp DataManagement/mitkPropertyList.cpp DataManagement/mitkPropertyListReplacedObserver.cpp DataManagement/mitkPropertyNameHelper.cpp DataManagement/mitkPropertyObserver.cpp DataManagement/mitkPropertyPersistence.cpp DataManagement/mitkPropertyPersistenceInfo.cpp DataManagement/mitkProportionalTimeGeometry.cpp DataManagement/mitkRenderingModeProperty.cpp DataManagement/mitkResliceMethodProperty.cpp DataManagement/mitkRestorePlanePositionOperation.cpp DataManagement/mitkRotationOperation.cpp DataManagement/mitkScaleOperation.cpp DataManagement/mitkSlicedData.cpp DataManagement/mitkSlicedGeometry3D.cpp DataManagement/mitkSmartPointerProperty.cpp DataManagement/mitkStandaloneDataStorage.cpp DataManagement/mitkStringProperty.cpp DataManagement/mitkSurface.cpp DataManagement/mitkSurfaceOperation.cpp DataManagement/mitkThinPlateSplineCurvedGeometry.cpp DataManagement/mitkTimeGeometry.cpp DataManagement/mitkTransferFunction.cpp DataManagement/mitkTransferFunctionInitializer.cpp DataManagement/mitkTransferFunctionProperty.cpp DataManagement/mitkTemporoSpatialStringProperty.cpp DataManagement/mitkVector.cpp DataManagement/mitkVectorProperty.cpp DataManagement/mitkVtkInterpolationProperty.cpp DataManagement/mitkVtkRepresentationProperty.cpp DataManagement/mitkVtkResliceInterpolationProperty.cpp DataManagement/mitkVtkScalarModeProperty.cpp DataManagement/mitkVtkVolumeRenderingProperty.cpp DataManagement/mitkWeakPointerProperty.cpp Interactions/mitkAction.cpp Interactions/mitkBindDispatcherInteractor.cpp Interactions/mitkCrosshairPositionEvent.cpp - Interactions/mitkCustomDisplayActionEventHandler.cpp Interactions/mitkDataInteractor.cpp Interactions/mitkDispatcher.cpp Interactions/mitkDisplayCoordinateOperation.cpp Interactions/mitkDisplayInteractor.cpp Interactions/mitkDisplayActionEventBroadcast.cpp + Interactions/mitkDisplayActionEventDefaultFunctions.cpp + Interactions/mitkDisplayActionEventHandler.cpp Interactions/mitkEventConfig.cpp Interactions/mitkEventFactory.cpp Interactions/mitkEventRecorder.cpp Interactions/mitkEventStateMachine.cpp Interactions/mitkInteractionEventConst.cpp Interactions/mitkInteractionEvent.cpp Interactions/mitkInteractionEventHandler.cpp Interactions/mitkInteractionEventObserver.cpp Interactions/mitkInteractionKeyEvent.cpp Interactions/mitkInteractionPositionEvent.cpp Interactions/mitkInternalEvent.cpp Interactions/mitkMouseDoubleClickEvent.cpp Interactions/mitkMouseModeSwitcher.cpp Interactions/mitkMouseMoveEvent.cpp Interactions/mitkMousePressEvent.cpp Interactions/mitkMouseReleaseEvent.cpp Interactions/mitkMouseWheelEvent.cpp Interactions/mitkPointSetDataInteractor.cpp Interactions/mitkSinglePointDataInteractor.cpp Interactions/mitkStateMachineAction.cpp Interactions/mitkStateMachineCondition.cpp Interactions/mitkStateMachineContainer.cpp Interactions/mitkStateMachineState.cpp Interactions/mitkStateMachineTransition.cpp Interactions/mitkStdDisplayActionEventHandler.cpp Interactions/mitkVtkEventAdapter.cpp Interactions/mitkVtkInteractorStyle.cxx Interactions/mitkXML2EventParser.cpp IO/mitkAbstractFileIO.cpp IO/mitkAbstractFileReader.cpp IO/mitkAbstractFileWriter.cpp IO/mitkCustomMimeType.cpp IO/mitkDicomSeriesReader.cpp IO/mitkDicomSeriesReaderService.cpp IO/mitkDicomSR_GantryTiltInformation.cpp IO/mitkDicomSR_ImageBlockDescriptor.cpp IO/mitkDicomSR_LoadDICOMRGBPixel4D.cpp IO/mitkDicomSR_LoadDICOMRGBPixel.cpp IO/mitkDicomSR_LoadDICOMScalar4D.cpp IO/mitkDicomSR_LoadDICOMScalar.cpp IO/mitkDicomSR_SliceGroupingResult.cpp IO/mitkFileReader.cpp IO/mitkFileReaderRegistry.cpp IO/mitkFileReaderSelector.cpp IO/mitkFileReaderWriterBase.cpp IO/mitkFileWriter.cpp IO/mitkFileWriterRegistry.cpp IO/mitkFileWriterSelector.cpp IO/mitkGeometry3DToXML.cpp IO/mitkIFileIO.cpp IO/mitkIFileReader.cpp IO/mitkIFileWriter.cpp IO/mitkGeometryDataReaderService.cpp IO/mitkGeometryDataWriterService.cpp IO/mitkImageGenerator.cpp IO/mitkImageVtkLegacyIO.cpp IO/mitkImageVtkXmlIO.cpp IO/mitkIMimeTypeProvider.cpp IO/mitkIOConstants.cpp IO/mitkIOMimeTypes.cpp IO/mitkIOUtil.cpp IO/mitkItkImageIO.cpp IO/mitkItkLoggingAdapter.cpp IO/mitkLegacyFileReaderService.cpp IO/mitkLegacyFileWriterService.cpp IO/mitkLocaleSwitch.cpp IO/mitkLog.cpp IO/mitkMimeType.cpp IO/mitkMimeTypeProvider.cpp IO/mitkOperation.cpp IO/mitkPixelType.cpp IO/mitkPointSetReaderService.cpp IO/mitkPointSetWriterService.cpp IO/mitkProportionalTimeGeometryToXML.cpp IO/mitkRawImageFileReader.cpp IO/mitkStandardFileLocations.cpp IO/mitkSurfaceStlIO.cpp IO/mitkSurfaceVtkIO.cpp IO/mitkSurfaceVtkLegacyIO.cpp IO/mitkSurfaceVtkXmlIO.cpp IO/mitkVtkLoggingAdapter.cpp IO/mitkPreferenceListReaderOptionsFunctor.cpp Rendering/mitkAbstractAnnotationRenderer.cpp Rendering/mitkAnnotationUtils.cpp Rendering/mitkBaseRenderer.cpp #Rendering/mitkGLMapper.cpp Moved to deprecated LegacyGL Module Rendering/mitkGradientBackground.cpp Rendering/mitkImageVtkMapper2D.cpp Rendering/mitkMapper.cpp Rendering/mitkAnnotation.cpp Rendering/mitkPlaneGeometryDataMapper2D.cpp Rendering/mitkPlaneGeometryDataVtkMapper3D.cpp Rendering/mitkPointSetVtkMapper2D.cpp Rendering/mitkPointSetVtkMapper3D.cpp Rendering/mitkRenderWindowBase.cpp Rendering/mitkRenderWindow.cpp Rendering/mitkRenderWindowFrame.cpp #Rendering/mitkSurfaceGLMapper2D.cpp Moved to deprecated LegacyGL Module Rendering/mitkSurfaceVtkMapper2D.cpp Rendering/mitkSurfaceVtkMapper3D.cpp Rendering/mitkVtkEventProvider.cpp Rendering/mitkVtkMapper.cpp Rendering/mitkVtkPropRenderer.cpp Rendering/mitkVtkWidgetRendering.cpp Rendering/vtkMitkLevelWindowFilter.cpp Rendering/vtkMitkRectangleProp.cpp Rendering/vtkMitkRenderProp.cpp Rendering/vtkMitkThickSlicesFilter.cpp Rendering/vtkNeverTranslucentTexture.cpp ) set(RESOURCE_FILES Interactions/globalConfig.xml Interactions/DisplayInteraction.xml Interactions/DisplayConfig.xml Interactions/DisplayConfigPACS.xml Interactions/DisplayConfigPACSPan.xml Interactions/DisplayConfigPACSScroll.xml Interactions/DisplayConfigPACSZoom.xml Interactions/DisplayConfigPACSLevelWindow.xml Interactions/DisplayConfigMITK.xml Interactions/DisplayConfigMITKNoCrosshair.xml Interactions/DisplayConfigMITKRotation.xml Interactions/DisplayConfigMITKRotationUnCoupled.xml Interactions/DisplayConfigMITKSwivel.xml Interactions/DisplayConfigMITKLimited.xml Interactions/PointSet.xml Interactions/Legacy/StateMachine.xml Interactions/Legacy/DisplayConfigMITKTools.xml Interactions/PointSetConfig.xml mitkLevelWindowPresets.xml mitkAnatomicalStructureColorPresets.xml ) diff --git a/Modules/Core/include/mitkDisplayActionEventBroadcast.h b/Modules/Core/include/mitkDisplayActionEventBroadcast.h index 04adff11d4..d573f09a2b 100644 --- a/Modules/Core/include/mitkDisplayActionEventBroadcast.h +++ b/Modules/Core/include/mitkDisplayActionEventBroadcast.h @@ -1,220 +1,218 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical Image Computing. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKDISPLAYACTIONEVENTBROADCAST_H #define MITKDISPLAYACTIONEVENTBROADCAST_H #include "mitkInteractionEventObserver.h" #include namespace mitk { /** - * @brief This class serves as a event state machine while simultaneously observing interaction events. - * d - * - * + * @brief This class serves as an event state machine while simultaneously observing interaction events. + * It connects the actions from the event state machine .xml-file with concrete functions of this class. */ class MITKCORE_EXPORT DisplayActionEventBroadcast : public EventStateMachine, public InteractionEventObserver { public: mitkClassMacro(DisplayActionEventBroadcast, EventStateMachine) itkFactorylessNewMacro(Self) itkCloneMacro(Self) /** * By this function this observer is notified about about every 'InteractionEvent'. * The interaction event is passed to the state machine in order to use its infrastructure. * For more information see @see InteractionEventObserver. * * @par interactionEvent The event that was observed and triggered this notification. * @par isHandled Flag that indicates if a 'DataInteractor' has already handled the event. */ virtual void Notify(InteractionEvent* interactionEvent, bool isHandled) override; protected: DisplayActionEventBroadcast(); virtual ~DisplayActionEventBroadcast() override; /** * @brief Connects the action names used in the state machine pattern with functions implemented within this InteractionEventObserver. */ void ConnectActionsAndFunctions() override; /** * @brief This function is executed when a config object is set / changed (via 'SetEventConfig' or 'AddEventConfig' in 'InteractionEventObserver'). * It is used to read out the parameters set in the configuration file and to set the member variables accordingly. */ virtual void ConfigurationChanged() override; /** * @brief Filters the event resp. the sender of the event. * * @par interactionEvent The event whose sender has to be checked * @par data node The data node is ignored in this specific implementation. * * @return True, if the sender of the event is a valid sender and the sending renderer is a 2D-renderer. False, if not. */ virtual bool FilterEvents(InteractionEvent* interactionEvent, DataNode* dataNode) override; ////////////////////////////////////////////////////////////////////////// // Functions to react to interaction events (actions) ////////////////////////////////////////////////////////////////////////// /** * @brief Check if the given interaction event is actually an 'InteractionPositionEvent'. * * @par interactionEvent The interaction event that is checked. * * @return True, if the given event can be dynamically cast to an 'InteractionPositionEvent'. False, if not. */ virtual bool CheckPositionEvent(const InteractionEvent* interactionEvent); virtual bool CheckRotationPossible(const InteractionEvent* interactionEvent); virtual bool CheckSwivelPossible(const InteractionEvent* interactionEvent); virtual void Init(StateMachineAction* stateMachineAction, InteractionEvent* interactionEvent); virtual void Move(StateMachineAction* stateMachineAction , InteractionEvent* interactionEvent); virtual void SetCrosshair(StateMachineAction* stateMachineAction, InteractionEvent* interactionEvent); virtual void Zoom(StateMachineAction* stateMachineAction, InteractionEvent* interactionEvent); virtual void Scroll(StateMachineAction* stateMachineAction, InteractionEvent* interactionEvent); virtual void ScrollOneDown(StateMachineAction* stateMachineAction, InteractionEvent* interactionEvent); virtual void ScrollOneUp(StateMachineAction* stateMachineAction, InteractionEvent* interactionEvent); virtual void AdjustLevelWindow(StateMachineAction* stateMachineAction, InteractionEvent* interactionEvent); virtual void StartRotation(StateMachineAction* stateMachineAction, InteractionEvent* interactionEvent); virtual void EndRotation(StateMachineAction* stateMachineAction, InteractionEvent* interactionEvent); virtual void Rotate(StateMachineAction* stateMachineAction, InteractionEvent* interactionEvent); virtual void Swivel(StateMachineAction* stateMachineAction, InteractionEvent* interactionEvent); private: virtual void UpdateStatusbar(StateMachineAction* stateMachineAction, InteractionEvent* interactionEvent); bool GetBoolProperty(mitk::PropertyList::Pointer propertyList, const char* propertyName, bool defaultValue); mitk::DataNode::Pointer GetTopLayerNode(mitk::DataStorage::SetOfObjects::ConstPointer nodes, mitk::Point3D worldposition, BaseRenderer* renderer); /** * @brief Reference to the service registration of the observer. * This is needed to unregister the observer on unload. */ us::ServiceRegistration m_ServiceRegistration; /** * @brief Determines if this broadcast class reacts to events that already have been processed by a DataInteractor. * The default value is false. */ bool m_AlwaysReact; /** * @brief Coordinate of the mouse pointer at beginning of an interaction (translated to mm unit). */ mitk::Point2D m_StartCoordinateInMM; /** * @brief Coordinate of the mouse pointer in the last step within an interaction. */ mitk::Point2D m_LastDisplayCoordinate; /** * @brief Coordinate of the mouse pointer in the last step within an interaction (translated to mm unit). */ mitk::Point2D m_LastCoordinateInMM; /** * \brief Current coordinates of the pointer. */ mitk::Point2D m_CurrentDisplayCoordinate; /** * @brief Defines the behavior at the end of a data set. * If set to true, it will restart at end of data set from the beginning. */ bool m_AutoRepeat; /** * @brief Defines how many slices are scrolled per pixel that the mouse pointer was 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 the scroll behavior. * Default is up/down movement of pointer performs scrolling */ std::string m_ScrollDirection; /** * @brief Defines how the axis of interaction influences scroll behavior. */ bool m_InvertScrollDirection; /** * @brief Defines the zoom behavior. * Default is up/down movement of pointer performs zooming */ std::string m_ZoomDirection; /** * @brief Defines how the axis of interaction influences zoom behavior. */ bool m_InvertZoomDirection; /** * @brief Factor to adjust zooming speed. */ float m_ZoomFactor; /** * @brief Defines how the axis of interaction influences move behavior. */ bool m_InvertMoveDirection; /** * @brief Defines the level-window behavior. * Default is left/right movement of pointer modifies the level. */ std::string m_LevelDirection; /** * @brief Defines how the axis of interaction influences level-window behavior. */ bool m_InvertLevelWindowDirection; /** * @brief Determines if the angle between crosshair remains fixed when rotating. */ bool m_LinkPlanes; typedef std::vector SNCVector; SNCVector m_RotatableSNCs; SNCVector m_SNCsToBeRotated; Point3D m_LastCursorPosition; Point3D m_CenterOfRotation; Point2D m_ReferenceCursor; Vector3D m_RotationPlaneNormal; Vector3D m_RotationPlaneXVector; Vector3D m_RotationPlaneYVector; Vector3D m_PreviousRotationAxis; ScalarType m_PreviousRotationAngle; }; } #endif // MITKDISPLAYACTIONEVENTBROADCAST_H diff --git a/Modules/Core/include/mitkDisplayActionEventDefaultFunctions.h b/Modules/Core/include/mitkDisplayActionEventDefaultFunctions.h new file mode 100644 index 0000000000..ddb41527e9 --- /dev/null +++ b/Modules/Core/include/mitkDisplayActionEventDefaultFunctions.h @@ -0,0 +1,52 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical Image Computing. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef MITKDISPLAYACTIONEVENTDEFAULTFUNCTIONS_H +#define MITKDISPLAYACTIONEVENTDEFAULTFUNCTIONS_H + +namespace mitk +{ + namespace DisplayActionEventDefaultFunctions + { + /** + * @brief Registers a command as observer of the observable broadcast class. + * This command reacts on the 'DisplayMoveEvent' and performs a move of the camera controller + * by a vector that was previously determined by the mouse interaction event. + */ + StdFunctionCommand::ActionFunction DefaultMoveAction(); + /** + * @brief Registers a command as observer of the observable broadcast class. + * This command reacts on the 'DisplaySetCrosshairEvent' and performs a slice selection of the slice navigation controller. + * The new position was previously determined by the mouse interaction event. + */ + StdFunctionCommand::ActionFunction DefaultSetCrosshairAction(); + /** + * @brief Registers a command as observer of the observable broadcast class. + * This command reacts on the 'DisplayZoomEvent' and performs a zoom of the camera controller + * by a zoom factor that was previously determined by the mouse interaction event. + */ + StdFunctionCommand::ActionFunction DefaultZoomAction(); + /** + * @brief Registers a command as observer of the observable broadcast class. + * This command reacts on the 'DisplayScrollEvent' and performs a slice selection of the slice navigation controller. + * The new position was previously determined by the mouse interaction event. + */ + StdFunctionCommand::ActionFunction DefaultScrollAction(); + + } // end namespace DisplayActionEventDefaultFunctions +} // end namespace mitk + +#endif // MITKDISPLAYACTIONEVENTDEFAULTFUNCTIONS_H diff --git a/Modules/Core/include/mitkCustomDisplayActionEventHandler.h b/Modules/Core/include/mitkDisplayActionEventHandler.h similarity index 91% rename from Modules/Core/include/mitkCustomDisplayActionEventHandler.h rename to Modules/Core/include/mitkDisplayActionEventHandler.h index 68eb37b6c9..de83a934cc 100644 --- a/Modules/Core/include/mitkCustomDisplayActionEventHandler.h +++ b/Modules/Core/include/mitkDisplayActionEventHandler.h @@ -1,96 +1,91 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical Image Computing. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#ifndef MITKCUSTOMDISPLAYACTIONEVENTHANDLER_H -#define MITKCUSTOMDISPLAYACTIONEVENTHANDLER_H +#ifndef MITKDISPLAYACTIONEVENTHANDLER_H +#define MITKDISPLAYACTIONEVENTHANDLER_H #include // mitk core #include "mitkDisplayActionEventBroadcast.h" -#include "mitkDisplayInteractor.h" #include "mitkDisplayActionEvents.h" #include "mitkStdFunctionCommand.h" -#include "mitkWeakPointer.h" - -// c++ -#include namespace mitk { - class MITKCORE_EXPORT CustomDisplayActionEventHandler + class MITKCORE_EXPORT DisplayActionEventHandler { public: using OberserverTagType = unsigned long; /** * @brief Sets the display action event broadcast class that should be observed. * This class receives events from the given broadcast class and triggers the "corresponding functions" to perform the custom actions. * "Corresponding functions" are std::functions inside commands that observe the specific display action event. * * @post If the same broadcast class was already set, nothing changed * @post If a different broadcast class was already set, the observing commands are removed as observer. * Attention: All registered commands are removed from the list of observer. * * @par observableBroadcast The 'DisplayActionEventBroadcast'-class that should be observed. */ void SetObservableBroadcast(mitk::DisplayActionEventBroadcast* observableBroadcast); /** * @brief Uses the given std::functions to customize a command: * The display action event is used to define on which event the command should react. * The display action event broadcast class member is then observed by the newly created command. * A tag for the command is returned and stored in a member vector. * * @pre The class' observable (the display action event broadcast) has to be set to connect display events. * @throw mitk::Exception, if the class' observable is null. * * @par displayActionEvent The 'DisplayActionEvent' on which the command should react. * @par actionFunction A custom std::Function that will be executed if the command receives the correct event. * @par filterFunction A custom std::Function that will be checked before the execution of the action function. * If the filter function is not specified, a default filter always returning 'true' will be used. * * @return A tag to identify, receive or remove the newly created 'StdFunctionCommand'. */ OberserverTagType ConnectDisplayActionEvent(const mitk::DisplayActionEvent& displayActionEvent, const mitk::StdFunctionCommand::ActionFunction& actionFunction, const mitk::StdFunctionCommand::FilterFunction& filterFunction = [](const itk::EventObject& eventObject) { return true; }); /** - * @brief Uses the given observer tag to remove the corresponding custom StdFunctionCommand as an observer of the observed + * @brief Uses the given observer tag to remove the corresponding custom command as an observer of the observed * display action event broadcast class. * If the given tag is not contained in the member vector of observer tags, nothing happens. * * @pre The class' observable (the display action event broadcast) has to be set to connect display events. * @throw mitk::Exception, if the class' observable is null. * * @par observerTag The tag to identify the 'StdFunctionCommand' observer. */ void DisconnectObserver(OberserverTagType observerTag); const std::vector& GetAllObserverTags() { return m_ObserverTags; }; - private: + protected: mitk::WeakPointer m_ObservableBroadcast; std::vector m_ObserverTags; }; } // end namespace mitk -#endif // MITKCUSTOMDISPLAYACTIONEVENTHANDLER_H +#endif // MITKDISPLAYACTIONEVENTHANDLER_H diff --git a/Modules/Core/include/mitkStdDisplayActionEventHandler.h b/Modules/Core/include/mitkStdDisplayActionEventHandler.h index 8f37438cf0..76758df9eb 100644 --- a/Modules/Core/include/mitkStdDisplayActionEventHandler.h +++ b/Modules/Core/include/mitkStdDisplayActionEventHandler.h @@ -1,87 +1,41 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical Image Computing. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef MITKSTDDISPLAYACTIONEVENTHANDLER_H #define MITKSTDDISPLAYACTIONEVENTHANDLER_H #include // mitk core -#include "mitkDisplayActionEventBroadcast.h" +#include "mitkDisplayActionEventHandler.h" namespace mitk { - class MITKCORE_EXPORT StdDisplayActionEventHandler + class MITKCORE_EXPORT StdDisplayActionEventHandler : public DisplayActionEventHandler { public: - using OberserverTagType = unsigned long; - /** - * @brief Sets the display action event broadcast class that should be observed. - * This class receives events from the given broadcast class and triggers the "corresponding functions" to perform the custom actions. - * "Corresponding functions" are std::functions inside commands that observe the specific display action event. - * - * @post If the same broadcast class was already set, nothing changed - * @post If a different broadcast class was already set, the observing commands are removed as observer. - * Attention: All registered commands are removed from the list of observer. - * - * @par observableBroadcast The 'DisplayActionEventBroadcast'-class that should be observed. - */ - void SetObservableBroadcast(mitk::DisplayActionEventBroadcast* observableBroadcast); - - /** - * @brief Initializes common standard display actions by calling the private 'ConnectDisplay...'-functions. + * @brief Initializes common standard display actions by using the default display action event functions. * * @pre The class' observable (the display action event broadcast) has to be set to connect display events. * @throw mitk::Exception, if the class' observable is null. */ void InitStdActions(); - - private: - - /** - * @brief Registers a command as observer of the observable broadcast class. - * This command reacts on the 'DisplayMoveEvent' and performs a move of the camera controller - * by a vector that was previously determined by the mouse interaction event. - */ - void ConnectDisplayMoveEvent(); - /** - * @brief Registers a command as observer of the observable broadcast class. - * This command reacts on the 'DisplaySetCrosshairEvent' and performs a slice selection of the slice navigation controller. - * The new position was previously determined by the mouse interaction event. - */ - void ConnectDisplaySetCrosshairEvent(); - /** - * @brief Registers a command as observer of the observable broadcast class. - * This command reacts on the 'DisplayZoomEvent' and performs a zoom of the camera controller - * by a zoom factor that was previously determined by the mouse interaction event. - */ - void ConnectDisplayZoomEvent(); - /** - * @brief Registers a command as observer of the observable broadcast class. - * This command reacts on the 'DisplayScrollEvent' and performs a slice selection of the slice navigation controller. - * The new position was previously determined by the mouse interaction event. - */ - void ConnectDisplayScrollEvent(); - - mitk::WeakPointer m_ObservableBroadcast; - std::vector m_ObserverTags; - }; } // end namespace mitk #endif // MITKSTDDISPLAYACTIONEVENTHANDLER_H diff --git a/Modules/Core/src/Interactions/mitkStdDisplayActionEventHandler.cpp b/Modules/Core/src/Interactions/mitkDisplayActionEventDefaultFunctions.cpp similarity index 57% copy from Modules/Core/src/Interactions/mitkStdDisplayActionEventHandler.cpp copy to Modules/Core/src/Interactions/mitkDisplayActionEventDefaultFunctions.cpp index 0da21a7eb1..c205962415 100644 --- a/Modules/Core/src/Interactions/mitkStdDisplayActionEventHandler.cpp +++ b/Modules/Core/src/Interactions/mitkDisplayActionEventDefaultFunctions.cpp @@ -1,154 +1,100 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical Image Computing. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#include "mitkStdDisplayActionEventHandler.h" - -// mitk core -#include "mitkBaseRenderer.h" -#include "mitkCameraController.h" -#include "mitkDisplayActionEvents.h" -#include "mitkStdFunctionCommand.h" +#include "DisplayActionEventDefaultFunctions.h" // itk #include -void mitk::StdDisplayActionEventHandler::SetObservableBroadcast(mitk::DisplayActionEventBroadcast* observableBroadcast) -{ - if (m_ObservableBroadcast == observableBroadcast) - { - // no need to update the broadcast class - return; - } - - if (m_ObservableBroadcast.IsNotNull()) - { - // remove current observer - for (const auto& tag : m_ObserverTags) - { - m_ObservableBroadcast->RemoveObserver(tag); - } - m_ObserverTags.clear(); - } - - // set new (possibly nullptr) broadcast class - m_ObservableBroadcast = observableBroadcast; -} - -void mitk::StdDisplayActionEventHandler::InitStdActions() -{ - // #TODO: change function call for new mitk::WeakPointer - if (m_ObservableBroadcast.IsNull()) - { - mitkThrow() << "No display action event broadcast class set to observe. Use 'SetObservableBroadcast' before initializing actions."; - } - - ConnectDisplayMoveEvent(); - ConnectDisplaySetCrosshairEvent(); - ConnectDisplayZoomEvent(); - ConnectDisplayScrollEvent(); -} - -void mitk::StdDisplayActionEventHandler::ConnectDisplayMoveEvent() +StdFunctionCommand::ActionFunction mitk::DisplayActionEventDefaultFunctions::DefaultMoveAction() { - auto command = StdFunctionCommand::New(); auto actionFunction = [](const itk::EventObject& displayInteractorEvent) { if (DisplayMoveEvent().CheckEvent(&displayInteractorEvent)) { const DisplayMoveEvent* displayActionEvent = dynamic_cast(&displayInteractorEvent); const BaseRenderer::Pointer sendingRenderer = displayActionEvent->GetInteractionEvent()->GetSender(); // concrete action sendingRenderer->GetCameraController()->MoveBy(displayActionEvent->GetMoveVector()); sendingRenderer->GetRenderingManager()->RequestUpdate(sendingRenderer->GetRenderWindow()); } }; - command->SetCommandAction(actionFunction); - unsigned long tag = m_ObservableBroadcast->AddObserver(DisplayMoveEvent(nullptr, Vector2D()), command); - m_ObserverTags.push_back(tag); + return actionFunction; } -void mitk::StdDisplayActionEventHandler::ConnectDisplaySetCrosshairEvent() +StdFunctionCommand::ActionFunction mitk::DisplayActionEventDefaultFunctions::DefaultSetCrosshairAction() { - auto command = StdFunctionCommand::New(); auto actionFunction = [](const itk::EventObject& displayInteractorEvent) { if (DisplaySetCrosshairEvent().CheckEvent(&displayInteractorEvent)) { const DisplaySetCrosshairEvent* displayActionEvent = dynamic_cast(&displayInteractorEvent); const BaseRenderer::Pointer sendingRenderer = displayActionEvent->GetInteractionEvent()->GetSender(); // concrete action auto allRenderWindows = sendingRenderer->GetRenderingManager()->GetAllRegisteredRenderWindows(); for (auto renWin : allRenderWindows) { if (BaseRenderer::GetInstance(renWin)->GetMapperID() == BaseRenderer::Standard2D && renWin != sendingRenderer->GetRenderWindow()) { BaseRenderer::GetInstance(renWin)->GetSliceNavigationController()->SelectSliceByPoint(displayActionEvent->GetPosition()); } } } }; - command->SetCommandAction(actionFunction); - unsigned long tag = m_ObservableBroadcast->AddObserver(DisplaySetCrosshairEvent(nullptr, Point3D()), command); - m_ObserverTags.push_back(tag); + return actionFunction; } -void mitk::StdDisplayActionEventHandler::ConnectDisplayZoomEvent() +void mitk::DisplayActionEventDefaultFunctions::DefaultZoomAction() { - auto command = StdFunctionCommand::New(); auto actionFunction = [](const itk::EventObject& displayInteractorEvent) { if (DisplayZoomEvent().CheckEvent(&displayInteractorEvent)) { const DisplayZoomEvent* displayActionEvent = dynamic_cast(&displayInteractorEvent); const BaseRenderer::Pointer sendingRenderer = displayActionEvent->GetInteractionEvent()->GetSender(); // concrete action if (1.0 != displayActionEvent->GetZoomFactor()) { sendingRenderer->GetCameraController()->Zoom(displayActionEvent->GetZoomFactor(), displayActionEvent->GetStartCoordinate()); sendingRenderer->GetRenderingManager()->RequestUpdate(sendingRenderer->GetRenderWindow()); } } }; - command->SetCommandAction(actionFunction); - unsigned long tag = m_ObservableBroadcast->AddObserver(DisplayZoomEvent(nullptr, 0.0, Point2D()), command); - m_ObserverTags.push_back(tag); + return actionFunction; } -void mitk::StdDisplayActionEventHandler::ConnectDisplayScrollEvent() +void mitk::DisplayActionEventDefaultFunctions::DefaultScrollAction() { - auto command = StdFunctionCommand::New(); auto actionFunction = [](const itk::EventObject& displayInteractorEvent) { if (DisplayScrollEvent().CheckEvent(&displayInteractorEvent)) { const DisplayScrollEvent* displayActionEvent = dynamic_cast(&displayInteractorEvent); const BaseRenderer::Pointer sendingRenderer = displayActionEvent->GetInteractionEvent()->GetSender(); // concrete action sendingRenderer->GetSliceNavigationController()->GetSlice()->SetPos(displayActionEvent->GetPosition()); } }; - command->SetCommandAction(actionFunction); - unsigned long tag = m_ObservableBroadcast->AddObserver(DisplayScrollEvent(nullptr, 0), command); - m_ObserverTags.push_back(tag); -} \ No newline at end of file + return; +} diff --git a/Modules/Core/src/Interactions/mitkCustomDisplayActionEventHandler.cpp b/Modules/Core/src/Interactions/mitkDisplayActionEventHandler.cpp similarity index 74% rename from Modules/Core/src/Interactions/mitkCustomDisplayActionEventHandler.cpp rename to Modules/Core/src/Interactions/mitkDisplayActionEventHandler.cpp index 5e3607a41c..6702cbae73 100644 --- a/Modules/Core/src/Interactions/mitkCustomDisplayActionEventHandler.cpp +++ b/Modules/Core/src/Interactions/mitkDisplayActionEventHandler.cpp @@ -1,76 +1,73 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical Image Computing. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#include "mitkCustomDisplayActionEventHandler.h" +#include "mitkDisplayActionEventHandler.h" -// c++ -#include - -void mitk::CustomDisplayActionEventHandler::SetObservableBroadcast(mitk::DisplayActionEventBroadcast* observableBroadcast) +void mitk::DisplayActionEventHandler::SetObservableBroadcast(mitk::DisplayActionEventBroadcast* observableBroadcast) { if (m_ObservableBroadcast == observableBroadcast) { // no need to update the broadcast class return; } if (m_ObservableBroadcast.IsNotNull()) { // remove current observer for (const auto& tag : m_ObserverTags) { m_ObservableBroadcast->RemoveObserver(tag); } m_ObserverTags.clear(); } // set new broadcast class (possibly nullptr) m_ObservableBroadcast = observableBroadcast; } -unsigned long mitk::CustomDisplayActionEventHandler::ConnectDisplayActionEvent(const mitk::DisplayActionEvent& displayActionEvent, +mitk::DisplayActionEventHandler::OberserverTagType mitk::DisplayActionEventHandler::ConnectDisplayActionEvent(const mitk::DisplayActionEvent& displayActionEvent, const mitk::StdFunctionCommand::ActionFunction& actionFunction, const mitk::StdFunctionCommand::FilterFunction& filterFunction) { // #TODO: change function call for new mitk::WeakPointer if (m_ObservableBroadcast.IsNull()) { mitkThrow() << "No display action event broadcast class set to observe. Use 'SetObservableBroadcast' before connecting events."; } auto command = mitk::StdFunctionCommand::New(); command->SetCommandAction(actionFunction); command->SetCommandFilter(filterFunction); - unsigned long tag = m_ObservableBroadcast->AddObserver(displayActionEvent, command); + OberserverTagType tag = m_ObservableBroadcast->AddObserver(displayActionEvent, command); m_ObserverTags.push_back(tag); return tag; } -void mitk::CustomDisplayActionEventHandler::DisconnectObserver(unsigned long observerTag) +void mitk::DisplayActionEventHandler::DisconnectObserver(OberserverTagType observerTag) { // #TODO: change function call for new mitk::WeakPointer if (m_ObservableBroadcast.IsNull()) { mitkThrow() << "No display action event broadcast class set to observe. Use 'SetObservableBroadcast' before disconnecting observer."; } - std::vector::iterator observerTagPosition = std::find(m_ObserverTags.begin(), m_ObserverTags.end(), observerTag); + std::vector::iterator observerTagPosition = std::find(m_ObserverTags.begin(), m_ObserverTags.end(), observerTag); if (observerTagPosition != m_ObserverTags.end()) { m_ObservableBroadcast->RemoveObserver(observerTag); m_ObserverTags.erase(observerTagPosition); } } diff --git a/Modules/Core/src/Interactions/mitkStdDisplayActionEventHandler.cpp b/Modules/Core/src/Interactions/mitkStdDisplayActionEventHandler.cpp index 0da21a7eb1..22452c5b7e 100644 --- a/Modules/Core/src/Interactions/mitkStdDisplayActionEventHandler.cpp +++ b/Modules/Core/src/Interactions/mitkStdDisplayActionEventHandler.cpp @@ -1,154 +1,44 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical Image Computing. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkStdDisplayActionEventHandler.h" // mitk core -#include "mitkBaseRenderer.h" -#include "mitkCameraController.h" -#include "mitkDisplayActionEvents.h" -#include "mitkStdFunctionCommand.h" +#include "mitkDisplayActionEventDefaultFunctions.h" // itk #include -void mitk::StdDisplayActionEventHandler::SetObservableBroadcast(mitk::DisplayActionEventBroadcast* observableBroadcast) -{ - if (m_ObservableBroadcast == observableBroadcast) - { - // no need to update the broadcast class - return; - } - - if (m_ObservableBroadcast.IsNotNull()) - { - // remove current observer - for (const auto& tag : m_ObserverTags) - { - m_ObservableBroadcast->RemoveObserver(tag); - } - m_ObserverTags.clear(); - } - - // set new (possibly nullptr) broadcast class - m_ObservableBroadcast = observableBroadcast; -} - void mitk::StdDisplayActionEventHandler::InitStdActions() { // #TODO: change function call for new mitk::WeakPointer if (m_ObservableBroadcast.IsNull()) { mitkThrow() << "No display action event broadcast class set to observe. Use 'SetObservableBroadcast' before initializing actions."; } - ConnectDisplayMoveEvent(); - ConnectDisplaySetCrosshairEvent(); - ConnectDisplayZoomEvent(); - ConnectDisplayScrollEvent(); -} + StdFunctionCommand::ActionFunction actionFunction = DisplayActionEventDefaultFunctions::DefaultMoveAction(); + ConnectDisplayActionEvent(DisplayMoveEvent(nullptr, Vector2D()), actionFunction); -void mitk::StdDisplayActionEventHandler::ConnectDisplayMoveEvent() -{ - auto command = StdFunctionCommand::New(); - auto actionFunction = [](const itk::EventObject& displayInteractorEvent) - { - if (DisplayMoveEvent().CheckEvent(&displayInteractorEvent)) - { - const DisplayMoveEvent* displayActionEvent = dynamic_cast(&displayInteractorEvent); - const BaseRenderer::Pointer sendingRenderer = displayActionEvent->GetInteractionEvent()->GetSender(); + StdFunctionCommand::ActionFunction actionFunction = DisplayActionEventDefaultFunctions::DefaultSetCrosshairAction(); + ConnectDisplayActionEvent(DisplaySetCrosshairEvent(nullptr, Point3D()), actionFunction); - // concrete action - sendingRenderer->GetCameraController()->MoveBy(displayActionEvent->GetMoveVector()); - sendingRenderer->GetRenderingManager()->RequestUpdate(sendingRenderer->GetRenderWindow()); - } - }; + StdFunctionCommand::ActionFunction actionFunction = DisplayActionEventDefaultFunctions::DefaultZoomAction(); + ConnectDisplayActionEvent(DisplayZoomEvent(nullptr, 0.0, Point2D()), actionFunction); - command->SetCommandAction(actionFunction); - unsigned long tag = m_ObservableBroadcast->AddObserver(DisplayMoveEvent(nullptr, Vector2D()), command); - m_ObserverTags.push_back(tag); + StdFunctionCommand::ActionFunction actionFunction = DisplayActionEventDefaultFunctions::DefaultScrollAction(); + ConnectDisplayActionEvent(DisplayScrollEvent(nullptr, 0), actionFunction); } - -void mitk::StdDisplayActionEventHandler::ConnectDisplaySetCrosshairEvent() -{ - auto command = StdFunctionCommand::New(); - auto actionFunction = [](const itk::EventObject& displayInteractorEvent) - { - if (DisplaySetCrosshairEvent().CheckEvent(&displayInteractorEvent)) - { - const DisplaySetCrosshairEvent* displayActionEvent = dynamic_cast(&displayInteractorEvent); - const BaseRenderer::Pointer sendingRenderer = displayActionEvent->GetInteractionEvent()->GetSender(); - - // concrete action - auto allRenderWindows = sendingRenderer->GetRenderingManager()->GetAllRegisteredRenderWindows(); - for (auto renWin : allRenderWindows) - { - if (BaseRenderer::GetInstance(renWin)->GetMapperID() == BaseRenderer::Standard2D && renWin != sendingRenderer->GetRenderWindow()) - { - BaseRenderer::GetInstance(renWin)->GetSliceNavigationController()->SelectSliceByPoint(displayActionEvent->GetPosition()); - } - } - } - }; - - command->SetCommandAction(actionFunction); - unsigned long tag = m_ObservableBroadcast->AddObserver(DisplaySetCrosshairEvent(nullptr, Point3D()), command); - m_ObserverTags.push_back(tag); -} - -void mitk::StdDisplayActionEventHandler::ConnectDisplayZoomEvent() -{ - auto command = StdFunctionCommand::New(); - auto actionFunction = [](const itk::EventObject& displayInteractorEvent) - { - if (DisplayZoomEvent().CheckEvent(&displayInteractorEvent)) - { - const DisplayZoomEvent* displayActionEvent = dynamic_cast(&displayInteractorEvent); - const BaseRenderer::Pointer sendingRenderer = displayActionEvent->GetInteractionEvent()->GetSender(); - - // concrete action - if (1.0 != displayActionEvent->GetZoomFactor()) - { - sendingRenderer->GetCameraController()->Zoom(displayActionEvent->GetZoomFactor(), displayActionEvent->GetStartCoordinate()); - sendingRenderer->GetRenderingManager()->RequestUpdate(sendingRenderer->GetRenderWindow()); - } - } - }; - - command->SetCommandAction(actionFunction); - unsigned long tag = m_ObservableBroadcast->AddObserver(DisplayZoomEvent(nullptr, 0.0, Point2D()), command); - m_ObserverTags.push_back(tag); -} - -void mitk::StdDisplayActionEventHandler::ConnectDisplayScrollEvent() -{ - auto command = StdFunctionCommand::New(); - auto actionFunction = [](const itk::EventObject& displayInteractorEvent) - { - if (DisplayScrollEvent().CheckEvent(&displayInteractorEvent)) - { - const DisplayScrollEvent* displayActionEvent = dynamic_cast(&displayInteractorEvent); - const BaseRenderer::Pointer sendingRenderer = displayActionEvent->GetInteractionEvent()->GetSender(); - - // concrete action - sendingRenderer->GetSliceNavigationController()->GetSlice()->SetPos(displayActionEvent->GetPosition()); - } - }; - - command->SetCommandAction(actionFunction); - unsigned long tag = m_ObservableBroadcast->AddObserver(DisplayScrollEvent(nullptr, 0), command); - m_ObserverTags.push_back(tag); -} \ No newline at end of file