diff --git a/src/store/ActionTypes.js b/src/store/ActionTypes.js index 0e013d32..998c4df6 100644 --- a/src/store/ActionTypes.js +++ b/src/store/ActionTypes.js @@ -55,5 +55,6 @@ const StoreActionType = { SET_SHOW_MODAL_SELECT_FILES: 43, SET_SELECTED_COLOR: 44, SET_DEFAULT_3D_POSITION: 45, + SET_LUNGS_SEED_STATUS: 46, }; export default StoreActionType; diff --git a/src/store/Store.js b/src/store/Store.js index 4b379e24..50f96fe1 100644 --- a/src/store/Store.js +++ b/src/store/Store.js @@ -54,6 +54,7 @@ export const initialState = { showModalSelectFiles: false, selectedColor: '#ffff00', isDefault3dPosition: false, + lungsSeedStatus: false, }; // // App reducer @@ -150,6 +151,9 @@ const medReducer = (state = initialState, action) => { return Object.assign({}, state, { selectedColor: action.selectedColor }); case StoreActionType.SET_DEFAULT_3D_POSITION: return Object.assign({}, state, { isDefault3dPosition: action.isDefault3dPosition }); + case StoreActionType.SET_LUNGS_SEED_STATUS: + return Object.assign({}, state, { lungsSeedStatus: action.lungsSeedStatus }); + default: return state; } diff --git a/src/ui/Main.jsx b/src/ui/Main.jsx index a2d75ba0..75c664b5 100644 --- a/src/ui/Main.jsx +++ b/src/ui/Main.jsx @@ -41,9 +41,17 @@ import PositionTool3D from './Toolbars/PositionTool3D'; export const Main = () => { const dispatch = useDispatch(); - const { isLoaded, progress, spinner, viewMode, showModalText, showModalAlert, showModalWindowCW, showModalConfirmation } = useSelector( - (state) => state - ); + const { + isLoaded, + progress, + spinner, + viewMode, + showModalText, + showModalAlert, + showModalWindowCW, + showModalConfirmation, + lungsSeedStatus, + } = useSelector((state) => state); const [m_fileNameOnLoad, setM_fileNameOnLoad] = useState(false); const [isWebGl20supported, setIsWebGl20supported] = useState(true); @@ -188,6 +196,16 @@ export const Main = () => { useOnEvent(mriEventsService.FILE_READ_SUCCESS, onHide); + //Alret message does not catch all cases then loaded image, which does not contain lungs + useEffect(() => { + if (lungsSeedStatus) { + setStrAlertTitle('Attention!'); + setStrAlertText(' Please note, the uploaded image may not contain lungs!'); + onShowModalAlert(); + dispatch({ type: StoreActionType.SET_LUNGS_SEED_STATUS, lungsSeedStatus: false }); + } + }); + return (
diff --git a/src/ui/TopToolbar/Filter/Jobs/lungsFillJob.js b/src/ui/TopToolbar/Filter/Jobs/lungsFillJob.js index 7a83edf7..1fe62b8d 100644 --- a/src/ui/TopToolbar/Filter/Jobs/lungsFillJob.js +++ b/src/ui/TopToolbar/Filter/Jobs/lungsFillJob.js @@ -6,23 +6,25 @@ import SeedPoints from '../../../../engine/actvolume/lungsfill/seedPoints'; import FloodFillTool from '../../../../engine/actvolume/lungsfill/floodfill'; -const getSeedPointOnCentralSlice = (volTexSrc, xDim, yDim, zDim) => { +const getSeedPointOnCentralSlice = (volTexSrc, xDim, yDim, zDim, setSeed) => { let vSeed = { x: 0, y: 0, z: 0 }; const seedPoints = new SeedPoints(volTexSrc, xDim, yDim, zDim); const resFind = seedPoints.findSeedPointOnCentralSlice(vSeed); if (resFind) { console.log('Lungs Central fill run: seed point not found'); + setSeed(true); return false; } return vSeed; }; -const getSeedPointOnFirstSlice = (volTexSrc, xDim, yDim, zDim) => { +const getSeedPointOnFirstSlice = (volTexSrc, xDim, yDim, zDim, setSeed) => { let vSeed = { x: 0, y: 0, z: 0 }; const seedPoints = new SeedPoints(volTexSrc, xDim, yDim, zDim); const resFind = seedPoints.findSeedPointOnFirstSlice(vSeed); if (resFind) { console.log('Airway fill run: seed point not found'); + setSeed(true); return false; } return vSeed; @@ -111,7 +113,7 @@ const detectNonEmptyBox = (xDim, yDim, zDim, volTexMask) => { return { xBorderMin, xBorderMax, yBorderMin, yBorderMax }; }; -export const lungsFillJob = (volume) => { +export const lungsFillJob = (volume, setSeed) => { let xDim = volume.m_xDim; let yDim = volume.m_yDim; let zDim = volume.m_zDim; @@ -197,7 +199,7 @@ export const lungsFillJob = (volume) => { const run = () => { if (getProgress() === 0) { - seedOnCentralSlice = getSeedPointOnCentralSlice(volTexSrc, xDim, yDim, zDim); + seedOnCentralSlice = getSeedPointOnCentralSlice(volTexSrc, xDim, yDim, zDim, setSeed); if (!seedOnCentralSlice) { setProgress(0); return true; @@ -231,7 +233,7 @@ export const lungsFillJob = (volume) => { volTexMask1[i] = volTexSrc[i]; } - seedOnFirstSlice = getSeedPointOnFirstSlice(volTexSrc, xDim, yDim, zDim); + seedOnFirstSlice = getSeedPointOnFirstSlice(volTexSrc, xDim, yDim, zDim, setSeed); if (!seedOnFirstSlice) { setProgress(0); return true; diff --git a/src/ui/TopToolbar/Filter/LungsTool.jsx b/src/ui/TopToolbar/Filter/LungsTool.jsx index 271f913d..1522c910 100644 --- a/src/ui/TopToolbar/Filter/LungsTool.jsx +++ b/src/ui/TopToolbar/Filter/LungsTool.jsx @@ -3,8 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -import React from 'react'; -import { useSelector } from 'react-redux'; +import React, { useState, useEffect } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import StoreActionType from '../../../store/ActionTypes'; import { ToolButton } from '../ToolButton'; import { checkVolume } from './checkVolume'; import { useAppContext } from '../../App/AppContext'; @@ -12,20 +13,32 @@ import { lungsFillJob } from './Jobs/lungsFillJob'; export const LungsTool = () => { const { startJob } = useAppContext(); + const dispatch = useDispatch(); const { volumeSet, volumeIndex, graphics2d } = useSelector((state) => state); const volume = volumeSet.getVolume(volumeIndex); + const [isSeed, setSeed] = useState(false); const handleChange = () => { if (!checkVolume(volume)) { return; } - startJob(lungsFillJob(volume), () => { + startJob(lungsFillJob(volume, setSeed), () => { // update render graphics2d.forceUpdate(); }); }; - return ; + useEffect(() => { + if (isSeed) { + dispatch({ type: StoreActionType.SET_LUNGS_SEED_STATUS, lungsSeedStatus: true }); + setSeed(false); + } + }, [isSeed]); + return ( + <> + + + ); };