import createZoomWithWheel from './zoomWithWheel' ; import createTrackCursor from './trackCursor' ; import { Cursor } from 'utils/constants' ; import { addUnnamedManualLandmark , addManualLandmark , } from 'actions/workspace' ; import { getExpectedNextManualLandmark , isAnalysisComplete , } from 'store/reducers/workspace/analyses' ; import { getActiveImageId } from 'store/reducers/workspace/image' ; export const createAddPoint = ( state ) : EditorTool => ( { ... createZoomWithWheel ( state ) , ... createTrackCursor ( state ) , onCanvasMouseEnter ( _ ) { if ( ! isAnalysisComplete ( state ) ) { } } , onCanvasMouseLeave ( _ ) { } , onCanvasLeftClick ( dispatch , x , y ) { const landmark = getExpectedNextManualLandmark ( state ) ; const imageId = getActiveImageId ( state ) ; const value = { x , y } ; if ( landmark !== null ) { dispatch ( addManualLandmark ( { imageId , symbol : landmark . symbol , value , } ) ) ; } else { dispatch ( addUnnamedManualLandmark ( { imageId , value , } ) ) ; } } , getCursorForCanvas ( ) { return Cursor . ADD_LANDMARK ; } , shouldShowLens : true , } ) ; export default createAddPoint ;