Current Dev State

This commit is contained in:
Tim Lorsbach
2025-06-23 20:13:54 +02:00
parent b4f9bb277d
commit ded50edaa2
22617 changed files with 4345095 additions and 174 deletions

View File

@ -0,0 +1,44 @@
/****************************************************************************
* Copyright 2017 EPAM Systems
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
export const basic = ['H', 'C', 'N', 'O', 'S', 'P',
'F', 'Cl', 'Br', 'I'];
export const atomCuts = {
"H": "h",
"C": "c",
"N": "n",
"O": "o",
"S": "s",
"P": "p",
"F": "f",
"Cl": "Shift+c",
"Br": "Shift+b",
"I": "i",
"A": "a"
};
export default Object.keys(atomCuts).reduce((res, label) => {
res[`atom-${label.toLowerCase()}`] = {
title: `Atom ${label}`,
shortcut: atomCuts[label],
action: {
tool: 'atom',
opts: { label }
}
};
return res;
}, {});

View File

@ -0,0 +1,38 @@
/****************************************************************************
* Copyright 2017 EPAM Systems
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
import molfile from '../../chem/molfile';
export default {
// original: for dev purposes
"force-update": {
shortcut: "Ctrl+Shift+r",
action: editor => {
editor.update(true);
}
},
"qs-serialize": {
shortcut: "Alt+Shift+r",
action: editor => {
const molStr = molfile.stringify(editor.struct());
const molQs = 'mol=' + encodeURIComponent(molStr).replace(/%20/g, '+');
const qs = document.location.search;
document.location.search = !qs ? '?' + molQs :
qs.search('mol=') === -1 ? qs + '&' + molQs :
qs.replace(/mol=[^&$]*/, molQs);
}
}
}

View File

@ -0,0 +1,184 @@
/****************************************************************************
* Copyright 2017 EPAM Systems
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
import tools from './tools';
import atoms from './atoms';
import zoom from './zoom';
import server from './server';
import debug from './debug';
import templates from './templates';
import { exec } from '../component/cliparea';
import { miewAction } from '../state/miew';
export default {
"new": {
shortcut: "Mod+Delete",
title: "Clear Canvas",
action: {
thunk: (dispatch, getState) => {
let editor = getState().editor;
if (!editor.struct().isBlank())
editor.struct(null);
dispatch({ type: 'ACTION', action: tools['select-lasso'].action });
}
}
},
"open": {
shortcut: "Mod+o",
title: "Open…",
action: { dialog: 'open' }
},
"save": {
shortcut: "Mod+s",
title: "Save As…",
action: { dialog: 'save' }
},
"undo": {
shortcut: "Mod+z",
title: "Undo",
action: editor => {
editor.undo();
},
disabled: editor => (
editor.historySize().undo === 0
)
},
"redo": {
shortcut: ["Mod+Shift+z", "Mod+y"],
title: "Redo",
action: editor => {
editor.redo();
},
disabled: editor => (
editor.historySize().redo === 0
)
},
"cut": {
shortcut: "Mod+x",
title: "Cut",
action: () => {
exec('cut') || dontClipMessage('Cut');
},
disabled: editor => !hasSelection(editor)
},
"copy": {
shortcut: "Mod+c",
title: "Copy",
action: () => {
exec('copy') || dontClipMessage('Copy');
},
disabled: editor => !hasSelection(editor)
},
"paste": {
shortcut: "Mod+v",
title: "Paste",
action: () => {
exec('paste') || dontClipMessage('Paste')
},
selected: ({ actions }) => (
actions && // TMP
actions.active && actions.active.tool === 'paste'
)
},
"check": {
title: "Check Structure",
action: { dialog: 'check' },
disabled: (editor, server, options) => !options.app.server
},
"analyse": {
title: "Calculated Values",
action: { dialog: 'analyse' },
disabled: (editor, server, options) => !options.app.server
},
"recognize": {
title: "Recognize Molecule",
action: { dialog: 'recognize' },
disabled: (editor, server, options) => !options.app.server
},
"miew": {
title: "3D Viewer",
action: { thunk: miewAction },
disabled: (editor, server, options) => !options.app.server || !options.app.miewPath
},
"settings": {
title: "Settings",
action: { dialog: 'settings' }
},
"help": {
shortcut: ["?", "Shift+/"],
title: "Help",
action: { dialog: 'help' }
},
"about": {
title: "About",
action: { dialog: 'about' }
},
"reaction-automap": {
title: "Reaction Auto-Mapping Tool",
action: { dialog: 'automap' },
disabled: (editor, server, options) => !options.app.server || !editor.struct().hasRxnArrow()
},
"period-table": {
title: "Periodic Table",
action: { dialog: 'period-table' }
},
"select-all": {
title: "Select All",
shortcut: "Mod+a",
action: {
thunk: (dispatch, getState) => {
getState().editor.selection('all');
dispatch({ type: 'ACTION', action: tools['select-lasso'].action });
}
}
},
"deselect-all": {
title: "Deselect All",
shortcut: "Mod+Shift+a",
action: editor => {
editor.selection(null);
}
},
"select-descriptors": {
title: "Select descriptors",
shortcut: "Mod+d",
action: {
thunk: (dispatch, getState) => {
const editor = getState().editor;
editor.alignDescriptors();
editor.selection('descriptors');
dispatch({ type: 'ACTION', action: tools['select-lasso'].action });
}
}
},
...server,
...debug,
...tools,
...atoms,
...zoom,
...templates
};
function hasSelection(editor) {
let selection = editor.selection();
return selection && // if not only sgroupData selected
(Object.keys(selection).length > 1 || !selection.sgroupData);
}
function dontClipMessage(title) {
alert('These action is unavailble via menu.\n' +
'Instead, use shortcut to ' + title + '.');
}

View File

@ -0,0 +1,58 @@
/****************************************************************************
* Copyright 2017 EPAM Systems
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
import { serverTransform } from '../state/server';
export default {
"layout": {
shortcut: "Mod+l",
title: "Layout",
action: {
thunk: serverTransform('layout')
},
disabled: (editor, server, options) => !options.app.server
},
"clean": {
shortcut: "Mod+Shift+l",
title: "Clean Up",
action: {
thunk: serverTransform('clean')
},
disabled: (editor, server, options) => !options.app.server
},
"arom": {
title: "Aromatize",
action: {
thunk: serverTransform('aromatize')
},
disabled: (editor, server, options) => !options.app.server
},
"dearom": {
title: "Dearomatize",
action: {
thunk: serverTransform('dearomatize')
},
disabled: (editor, server, options) => !options.app.server
},
"cip": {
shortcut: "Mod+p",
title: "Calculate CIP",
action: {
thunk: serverTransform('calculateCip')
},
disabled: (editor, server, options) => !options.app.server
}
};

View File

@ -0,0 +1,39 @@
/****************************************************************************
* Copyright 2017 EPAM Systems
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
import templates from '../data/templates';
const templateLib = {
"template-lib": {
shortcut: "Shift+t",
title: "Custom Templates",
action: { dialog: 'templates' },
disabled: (editor, server, options) => !options.app.templates
}
};
export default templates.reduce((res, struct, i) => {
res[`template-${i}`] = {
title: `${struct.name}`,
shortcut: 't',
action: {
tool: 'template',
opts: { struct }
}
};
return res;
}, templateLib);

View File

@ -0,0 +1,142 @@
/****************************************************************************
* Copyright 2017 EPAM Systems
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
import { bond as bondSchema } from '../structschema';
import { toBondType } from '../structconv';
const toolActions = {
"select-lasso": {
title: "Lasso Selection",
shortcut: "Escape",
action: { tool: 'select', opts: 'lasso' }
},
"select-rectangle": {
title: "Rectangle Selection",
shortcut: "Escape",
action: { tool: 'select', opts: 'rectangle' }
},
"select-fragment": {
title: "Fragment Selection",
shortcut: "Escape",
action: { tool: 'select', opts: 'fragment' }
},
"erase": {
title: "Erase",
shortcut: ["Delete", "Backspace"],
action: { tool: 'eraser', opts: 1 } // TODO last selector mode is better
},
"chain": {
title: "Chain",
action: { tool: 'chain' }
},
"chiral-flag": {
title: "Chiral Flag",
action: { tool: 'chiralFlag' },
selected: editor => editor.struct().isChiral
},
"charge-plus": {
shortcut: "5",
title: "Charge Plus",
action: { tool: 'charge', opts: 1 }
},
"charge-minus": {
shortcut: "5",
title: "Charge Minus",
action: { tool: 'charge', opts: -1 }
},
"transform-rotate": {
shortcut: "Alt+r",
title: "Rotate Tool",
action: { tool: 'rotate' }
},
"transform-flip-h": {
shortcut: "Alt+h",
title: "Horizontal Flip",
action: { tool: 'rotate', opts: 'horizontal' }
},
"transform-flip-v": {
shortcut: "Alt+v",
title: "Vertical Flip",
action: { tool: 'rotate', opts: 'vertical' }
},
"sgroup": {
shortcut: "Mod+g",
title: "S-Group",
action: { tool: 'sgroup' }
},
"sgroup-data": {
shortcut: "Mod+g",
title: "Data S-Group",
action: { tool: 'sgroup', opts: 'DAT' }
},
"reaction-arrow": {
title: "Reaction Arrow Tool",
action: { tool: 'reactionarrow' }
},
"reaction-plus": {
title: "Reaction Plus Tool",
action: { tool: 'reactionplus' }
},
"reaction-map": {
title: "Reaction Mapping Tool",
action: { tool: 'reactionmap' }
},
"reaction-unmap": {
title: "Reaction Unmapping Tool",
action: { tool: 'reactionunmap' }
},
"rgroup-label": {
shortcut: "Mod+r",
title: "R-Group Label Tool",
action: { tool: 'rgroupatom' }
},
"rgroup-fragment": {
shortcut: ["Mod+Shift+r", "Mod+r"],
title: "R-Group Fragment Tool",
action: { tool: 'rgroupfragment' }
},
"rgroup-attpoints": {
shortcut: "Mod+r",
title: "Attachment Point Tool",
action: { tool: 'apoint' }
},
};
const bondCuts = {
"single": "1",
"double": "2",
"triple": "3",
"up": "1",
"down": "1",
"updown": "1",
"crossed": "2",
"any": "0",
"aromatic": "4",
};
const typeSchema = bondSchema.properties.type;
export default typeSchema.enum.reduce((res, type, i) => {
res[`bond-${type}`] = {
title: `${typeSchema.enumNames[i]} Bond`,
shortcut: bondCuts[type],
action: {
tool: 'bond',
opts: toBondType(type)
}
};
return res;
}, toolActions);

View File

@ -0,0 +1,56 @@
/****************************************************************************
* Copyright 2017 EPAM Systems
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
import { findIndex, findLastIndex } from 'lodash/fp';
export const zoomList = [
0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1,
1.1, 1.2, 1.3, 1.4, 1.5, 1.7, 2, 2.5, 3, 3.5, 4
];
export default {
"zoom": {
selected: editor => editor.zoom()
},
"zoom-out": {
shortcut: ["-", "_", "Shift+-"],
title: "Zoom Out",
disabled: editor => (
editor.zoom() <= zoomList[0] // unsave
),
action: editor => {
let zoom = editor.zoom();
let i = findIndex(z => z >= zoom, zoomList);
editor.zoom(
zoomList[(zoomList[i] === zoom && i > 0) ? i - 1 : i]
);
}
},
"zoom-in": {
shortcut: ["+", "=", "Shift+="],
title: "Zoom In",
disabled: editor => (
zoomList[zoomList.length - 1] <= editor.zoom()
),
action: editor => {
let zoom = editor.zoom();
let i = findLastIndex(z => z <= zoom, zoomList);
editor.zoom(
zoomList[(zoomList[i] === zoom && i < zoomList.length - 1) ? i + 1 : i]
);
}
}
}