Skip to content

Commit

Permalink
feat: create a workspace for simulation (#2532)
Browse files Browse the repository at this point in the history
* feat: add the simulation panel to general settings

* feat: add 'simulation' workspace

* chore(demo): add simulation example under Workspaces section

* feat: change the dimmedSpectraOpacity in the simulation workspace to 0.5

* feat: upgrade nmr-load-save to version 0.14.0

close #2527
  • Loading branch information
hamed-musallam committed Jul 21, 2023
1 parent 21b1e1b commit 1ca5910
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 7 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -86,7 +86,7 @@
"ml-stat": "^1.3.3",
"multiplet-analysis": "^2.1.1",
"nmr-correlation": "^2.3.3",
"nmr-load-save": "^0.13.6",
"nmr-load-save": "^0.14.0",
"nmr-processing": "^9.7.8",
"nmredata": "^0.9.2",
"numeral": "^2.0.6",
Expand Down
1 change: 1 addition & 0 deletions src/component/NMRium.tsx
Expand Up @@ -116,6 +116,7 @@ export type NMRiumWorkspace =
| 'prediction'
| 'embedded'
| 'assignment'
| 'simulation'
// eslint-disable-next-line @typescript-eslint/ban-types
| (string & {});

Expand Down
Expand Up @@ -64,6 +64,10 @@ const LIST: ListItem[] = [
label: 'Matrix generation Panel',
name: 'panels.matrixGenerationPanel',
},
{
label: 'Simulation panel',
name: 'panels.simulationPanel',
},
];

const COLUMNS: Array<CustomColumn<ListItem>> = [
Expand Down
3 changes: 1 addition & 2 deletions src/component/panels/Panels.tsx
Expand Up @@ -122,8 +122,7 @@ const accordionItems: AccordionItem[] = [
{
title: 'Spectrum Simulation',
component: <SpectrumSimulation />,
isExperimental: true,
hidePreferenceKey: '',
hidePreferenceKey: 'simulationPanel',
mode: DISPLAYER_MODE.DM_1D,
},
];
Expand Down
4 changes: 4 additions & 0 deletions src/component/reducer/preferences/preferencesReducer.ts
Expand Up @@ -165,6 +165,10 @@ export const WORKSPACES: Array<{
key: 'embedded',
label: Workspaces.embedded.label,
},
{
key: 'simulation',
label: Workspaces.simulation.label,
},
];

export type WorkspaceWithSource = Workspace & { source: WorkSpaceSource };
Expand Down
2 changes: 2 additions & 0 deletions src/component/workspaces/index.ts
Expand Up @@ -4,6 +4,7 @@ import { embedded } from './embedded';
import { exercise } from './exercise';
import { prediction } from './prediction';
import { process1D } from './process1D';
import { simulation } from './simulation';

export default {
exercise,
Expand All @@ -12,4 +13,5 @@ export default {
prediction,
assignment,
embedded,
simulation,
};
70 changes: 70 additions & 0 deletions src/component/workspaces/simulation.ts
@@ -0,0 +1,70 @@
import { InnerWorkspace } from 'nmr-load-save';

export const simulation: InnerWorkspace = {
version: 1,
label: 'Simulation',
general: {
dimmedSpectraOpacity: 0.5,
verticalSplitterPosition: '440px',
verticalSplitterCloseThreshold: 600,
spectraRendering: 'auto',
loggingLevel: 'info',
},
display: {
panels: {
spectraPanel: { display: true },
simulationPanel: { display: true, open: true },
},
toolBarButtons: {
exportAs: true,
import: true,
spectraCenterAlignments: true,
spectraStackAlignments: true,
zoomOut: true,
zoom: true,
},
},
formatting: {
nuclei: {},
panels: {
spectra: {
nuclei: {
'1H': {
columns: [
{
name: 'visible',
label: '',
description: 'Show/Hide Spectrum',
visible: true,
},
{
name: 'name',
label: 'Spectrum Name',
description: 'Spectrum Name',
jpath: ['info', 'name'],
visible: true,
},
{
label: 'Frequency',
description: 'frequency',
jpath: ['info', 'originFrequency'],
visible: true,
},
{
jpath: ['info', 'nucleus'],
label: 'Experiment',
visible: true,
},
{
name: 'color',
label: '',
description: 'Spectrum Color',
visible: true,
},
],
},
},
},
},
},
};
1 change: 1 addition & 0 deletions src/component/workspaces/workspaceDefaultProperties.ts
Expand Up @@ -24,6 +24,7 @@ export const workspaceDefaultProperties: Required<WorkspacePreferences> = {
peaksPanel: { display: false, open: false },
predictionPanel: { display: false, open: false },
summaryPanel: { display: false, open: false },
simulationPanel: { display: false, open: false },
},
toolBarButtons: {
baselineCorrection: false,
Expand Down
4 changes: 4 additions & 0 deletions src/demo/samples.json
Expand Up @@ -235,6 +235,10 @@
"title": "Prediction",
"view": "Prediction"
},
{
"title": "Simulation",
"view": "Simulation"
},
{
"title": "Metabo workspace",
"view": "CustomWorkspace"
Expand Down
5 changes: 5 additions & 0 deletions src/demo/views/Simulation.tsx
@@ -0,0 +1,5 @@
import View from './View';

export default function Simulation(props) {
return <View {...props} workspace="simulation" />;
}
1 change: 1 addition & 0 deletions src/demo/views/index.ts
Expand Up @@ -9,6 +9,7 @@ export const possibleViews = {
TwoInstances: memo(lazy(() => import('./TwoInstances'))),
Teaching: memo(lazy(() => import('./Teaching'))),
Prediction: memo(lazy(() => import('./Prediction'))),
Simulation: memo(lazy(() => import('./Simulation'))),
CustomWorkspace: memo(lazy(() => import('./CustomWorkspace'))),
SnapshotView: memo(lazy(() => import('./SnapshotView'))),
WebSourceView: memo(lazy(() => import('./WebSourceView'))),
Expand Down

0 comments on commit 1ca5910

Please sign in to comment.