-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: hide the 2D apodization feature behind the experimental flag
- Loading branch information
1 parent
40c01bb
commit 450d0e6
Showing
13 changed files
with
449 additions
and
34 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/component/header/SimpleApodizationDimensionOneOptionsPanel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { memo, useCallback } from 'react'; | ||
|
||
import type { ExtractFilterEntry } from '../../data/types/common/ExtractFilterEntry.js'; | ||
import { useDispatch } from '../context/DispatchContext.js'; | ||
import { useFilter } from '../hooks/useFilter.js'; | ||
|
||
import { BaseSimpleApodizationOptionsPanel } from './BaseSimpleApodizationOptionsPanel.js'; | ||
|
||
interface ApodizationOptionsInnerPanelProps { | ||
filter: ExtractFilterEntry<'apodizationDimension1'> | null; | ||
} | ||
|
||
function ApodizationOptionsInnerPanel( | ||
props: ApodizationOptionsInnerPanelProps, | ||
) { | ||
const dispatch = useDispatch(); | ||
|
||
const applyHandler = useCallback( | ||
(data) => { | ||
const { options } = data; | ||
dispatch({ | ||
type: 'APPLY_APODIZATION_DIMENSION_ONE_FILTER', | ||
payload: { options }, | ||
}); | ||
}, | ||
[dispatch], | ||
); | ||
const changeHandler = useCallback( | ||
(data) => { | ||
const { livePreview, options } = data; | ||
|
||
dispatch({ | ||
type: 'CALCULATE_APODIZATION_DIMENSION_ONE_FILTER', | ||
payload: { livePreview, options: structuredClone(options) }, | ||
}); | ||
}, | ||
[dispatch], | ||
); | ||
|
||
return ( | ||
<BaseSimpleApodizationOptionsPanel | ||
filter={props.filter} | ||
onApplyDispatch={applyHandler} | ||
onChangeDispatch={changeHandler} | ||
/> | ||
); | ||
} | ||
|
||
const MemoizedApodizationPanel = memo(ApodizationOptionsInnerPanel); | ||
|
||
export function SimpleApodizationDimensionOneOptionsPanel() { | ||
const filter = useFilter('apodizationDimension1'); | ||
return <MemoizedApodizationPanel filter={filter} />; | ||
} |
54 changes: 54 additions & 0 deletions
54
src/component/header/SimpleApodizationDimensionTwoOptionsPanel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { memo, useCallback } from 'react'; | ||
|
||
import type { ExtractFilterEntry } from '../../data/types/common/ExtractFilterEntry.js'; | ||
import { useDispatch } from '../context/DispatchContext.js'; | ||
import { useFilter } from '../hooks/useFilter.js'; | ||
|
||
import { BaseSimpleApodizationOptionsPanel } from './BaseSimpleApodizationOptionsPanel.js'; | ||
|
||
interface ApodizationOptionsInnerPanelProps { | ||
filter: ExtractFilterEntry<'apodizationDimension2'> | null; | ||
} | ||
|
||
function ApodizationOptionsInnerPanel( | ||
props: ApodizationOptionsInnerPanelProps, | ||
) { | ||
const dispatch = useDispatch(); | ||
|
||
const applyHandler = useCallback( | ||
(data) => { | ||
const { options } = data; | ||
dispatch({ | ||
type: 'APPLY_APODIZATION_DIMENSION_TWO_FILTER', | ||
payload: { options }, | ||
}); | ||
}, | ||
[dispatch], | ||
); | ||
const changeHandler = useCallback( | ||
(data) => { | ||
const { livePreview, options } = data; | ||
|
||
dispatch({ | ||
type: 'CALCULATE_APODIZATION_DIMENSION_TWO_FILTER', | ||
payload: { livePreview, options: structuredClone(options) }, | ||
}); | ||
}, | ||
[dispatch], | ||
); | ||
|
||
return ( | ||
<BaseSimpleApodizationOptionsPanel | ||
filter={props.filter} | ||
onApplyDispatch={applyHandler} | ||
onChangeDispatch={changeHandler} | ||
/> | ||
); | ||
} | ||
|
||
const MemoizedApodizationPanel = memo(ApodizationOptionsInnerPanel); | ||
|
||
export function SimpleApodizationDimensionTwoOptionsPanel() { | ||
const filter = useFilter('apodizationDimension2'); | ||
return <MemoizedApodizationPanel filter={filter} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/component/panels/filtersPanel/Filters/ApodizationDimensionOneOptionsPanel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { useCallback } from 'react'; | ||
|
||
import type { ExtractFilterEntry } from '../../../../data/types/common/ExtractFilterEntry.js'; | ||
import { useDispatch } from '../../../context/DispatchContext.js'; | ||
|
||
import { BaseApodizationOptions } from './apodization/BaseApodizationOptions.js'; | ||
|
||
import type { BaseFilterOptionsPanelProps } from './index.js'; | ||
|
||
export default function ApodizationDimensionOneOptionsPanel( | ||
props: BaseFilterOptionsPanelProps< | ||
ExtractFilterEntry<'apodizationDimension1'> | ||
>, | ||
) { | ||
const dispatch = useDispatch(); | ||
|
||
const { filter, enableEdit = true, onCancel, onConfirm } = props; | ||
|
||
const applyHandler = useCallback( | ||
(data) => { | ||
const { options } = data; | ||
dispatch({ | ||
type: 'APPLY_APODIZATION_DIMENSION_ONE_FILTER', | ||
payload: { options }, | ||
}); | ||
}, | ||
[dispatch], | ||
); | ||
const changeHandler = useCallback( | ||
(data) => { | ||
const { livePreview, options } = data; | ||
|
||
dispatch({ | ||
type: 'CALCULATE_APODIZATION_DIMENSION_ONE_FILTER', | ||
payload: { livePreview, options: structuredClone(options) }, | ||
}); | ||
}, | ||
[dispatch], | ||
); | ||
|
||
return ( | ||
<BaseApodizationOptions | ||
enableEdit={enableEdit} | ||
filter={filter} | ||
onCancel={onCancel} | ||
onConfirm={onConfirm} | ||
onApplyDispatch={applyHandler} | ||
onChangeDispatch={changeHandler} | ||
/> | ||
); | ||
} |
51 changes: 51 additions & 0 deletions
51
src/component/panels/filtersPanel/Filters/ApodizationDimensionTwoOptionsPanel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { useCallback } from 'react'; | ||
|
||
import type { ExtractFilterEntry } from '../../../../data/types/common/ExtractFilterEntry.js'; | ||
import { useDispatch } from '../../../context/DispatchContext.js'; | ||
|
||
import { BaseApodizationOptions } from './apodization/BaseApodizationOptions.js'; | ||
|
||
import type { BaseFilterOptionsPanelProps } from './index.js'; | ||
|
||
export default function ApodizationDimensionTwoOptionsPanel( | ||
props: BaseFilterOptionsPanelProps< | ||
ExtractFilterEntry<'apodizationDimension2'> | ||
>, | ||
) { | ||
const dispatch = useDispatch(); | ||
|
||
const { filter, enableEdit = true, onCancel, onConfirm } = props; | ||
|
||
const applyHandler = useCallback( | ||
(data) => { | ||
const { options } = data; | ||
dispatch({ | ||
type: 'APPLY_APODIZATION_DIMENSION_TWO_FILTER', | ||
payload: { options }, | ||
}); | ||
}, | ||
[dispatch], | ||
); | ||
const changeHandler = useCallback( | ||
(data) => { | ||
const { livePreview, options } = data; | ||
|
||
dispatch({ | ||
type: 'CALCULATE_APODIZATION_DIMENSION_TWO_FILTER', | ||
payload: { livePreview, options: structuredClone(options) }, | ||
}); | ||
}, | ||
[dispatch], | ||
); | ||
|
||
return ( | ||
<BaseApodizationOptions | ||
enableEdit={enableEdit} | ||
filter={filter} | ||
onCancel={onCancel} | ||
onConfirm={onConfirm} | ||
onApplyDispatch={applyHandler} | ||
onChangeDispatch={changeHandler} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.