mc-react-structure-visualizer 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -74
- package/dist/index.css +1 -3
- package/dist/main.js +24523 -0
- package/package.json +37 -58
- package/dist/ControlBox/index.css +0 -67
- package/dist/ControlBox/index.js +0 -116
- package/dist/StructureWindow/3dmol/Visualizer3dmol.css +0 -5
- package/dist/StructureWindow/3dmol/Visualizer3dmol.js +0 -136
- package/dist/StructureWindow/index.css +0 -43
- package/dist/StructureWindow/index.js +0 -66
- package/dist/index.js +0 -117
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -43
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +0 -25
- package/public/robots.txt +0 -3
- package/src/App.css +0 -38
- package/src/App.js +0 -40
- package/src/StructureVisualizer/ControlBox/index.css +0 -67
- package/src/StructureVisualizer/ControlBox/index.js +0 -94
- package/src/StructureVisualizer/StructureWindow/3dmol/Visualizer3dmol.css +0 -5
- package/src/StructureVisualizer/StructureWindow/3dmol/Visualizer3dmol.js +0 -108
- package/src/StructureVisualizer/StructureWindow/index.css +0 -43
- package/src/StructureVisualizer/StructureWindow/index.js +0 -46
- package/src/StructureVisualizer/index.css +0 -3
- package/src/StructureVisualizer/index.js +0 -87
- package/src/index.css +0 -13
- package/src/index.js +0 -17
- package/src/reportWebVitals.js +0 -13
package/dist/index.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports["default"] = void 0;
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _ControlBox = _interopRequireDefault(require("./ControlBox"));
|
|
10
|
-
var _StructureWindow = _interopRequireDefault(require("./StructureWindow"));
|
|
11
|
-
require("./index.css");
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
18
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
19
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
20
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
21
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
22
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
23
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
24
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
25
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
26
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
27
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
28
|
-
var StructureVisualizer = /*#__PURE__*/function (_React$Component) {
|
|
29
|
-
_inherits(StructureVisualizer, _React$Component);
|
|
30
|
-
var _super = _createSuper(StructureVisualizer);
|
|
31
|
-
function StructureVisualizer(props) {
|
|
32
|
-
var _this;
|
|
33
|
-
_classCallCheck(this, StructureVisualizer);
|
|
34
|
-
_this = _super.call(this, props);
|
|
35
|
-
_this.state = {
|
|
36
|
-
viewerParams: {
|
|
37
|
-
supercell: [2, 2, 2],
|
|
38
|
-
bonds: true,
|
|
39
|
-
atomLabels: false,
|
|
40
|
-
packedCell: false,
|
|
41
|
-
vdwRadius: false
|
|
42
|
-
},
|
|
43
|
-
mouseEnabled: false
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
// use Ref to send events to the visualizer backend
|
|
47
|
-
_this.visualizerRef = /*#__PURE__*/_react["default"].createRef();
|
|
48
|
-
|
|
49
|
-
// Ref to detect click outside
|
|
50
|
-
_this.wrapperRef = /*#__PURE__*/_react["default"].createRef();
|
|
51
|
-
_this.handleClickOutside = _this.handleClickOutside.bind(_assertThisInitialized(_this));
|
|
52
|
-
_this.handleViewerParamChange = _this.handleViewerParamChange.bind(_assertThisInitialized(_this));
|
|
53
|
-
_this.handleViewerEvent = _this.handleViewerEvent.bind(_assertThisInitialized(_this));
|
|
54
|
-
_this.setMouseEnabledState = _this.setMouseEnabledState.bind(_assertThisInitialized(_this));
|
|
55
|
-
return _this;
|
|
56
|
-
}
|
|
57
|
-
_createClass(StructureVisualizer, [{
|
|
58
|
-
key: "componentDidMount",
|
|
59
|
-
value: function componentDidMount() {
|
|
60
|
-
document.addEventListener("mousedown", this.handleClickOutside);
|
|
61
|
-
}
|
|
62
|
-
}, {
|
|
63
|
-
key: "componentWillUnmount",
|
|
64
|
-
value: function componentWillUnmount() {
|
|
65
|
-
document.removeEventListener("mousedown", this.handleClickOutside);
|
|
66
|
-
}
|
|
67
|
-
}, {
|
|
68
|
-
key: "handleClickOutside",
|
|
69
|
-
value: function handleClickOutside(event) {
|
|
70
|
-
if (this.wrapperRef && !this.wrapperRef.current.contains(event.target)) {
|
|
71
|
-
this.setState({
|
|
72
|
-
mouseEnabled: false
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}, {
|
|
77
|
-
key: "setMouseEnabledState",
|
|
78
|
-
value: function setMouseEnabledState(state) {
|
|
79
|
-
this.setState({
|
|
80
|
-
mouseEnabled: state
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}, {
|
|
84
|
-
key: "handleViewerParamChange",
|
|
85
|
-
value: function handleViewerParamChange(param, value) {
|
|
86
|
-
this.setState({
|
|
87
|
-
viewerParams: _objectSpread(_objectSpread({}, this.state.viewerParams), {}, _defineProperty({}, param, value))
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}, {
|
|
91
|
-
key: "handleViewerEvent",
|
|
92
|
-
value: function handleViewerEvent(param, value) {
|
|
93
|
-
this.visualizerRef.current.handleEvent(param, value);
|
|
94
|
-
}
|
|
95
|
-
}, {
|
|
96
|
-
key: "render",
|
|
97
|
-
value: function render() {
|
|
98
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
99
|
-
ref: this.wrapperRef,
|
|
100
|
-
className: "structure-visualizer"
|
|
101
|
-
}, /*#__PURE__*/_react["default"].createElement(_StructureWindow["default"], {
|
|
102
|
-
visualizerRef: this.visualizerRef,
|
|
103
|
-
viewerParams: this.state.viewerParams,
|
|
104
|
-
cifText: this.props.cifText,
|
|
105
|
-
mouseEnabled: this.state.mouseEnabled,
|
|
106
|
-
setMouseEnabledState: this.setMouseEnabledState
|
|
107
|
-
}), /*#__PURE__*/_react["default"].createElement(_ControlBox["default"], {
|
|
108
|
-
viewerParams: this.state.viewerParams,
|
|
109
|
-
onViewerParamChange: this.handleViewerParamChange,
|
|
110
|
-
onViewerEvent: this.handleViewerEvent
|
|
111
|
-
}));
|
|
112
|
-
}
|
|
113
|
-
}]);
|
|
114
|
-
return StructureVisualizer;
|
|
115
|
-
}(_react["default"].Component);
|
|
116
|
-
var _default = StructureVisualizer;
|
|
117
|
-
exports["default"] = _default;
|
package/public/favicon.ico
DELETED
|
Binary file
|
package/public/index.html
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
-
<meta name="theme-color" content="#000000" />
|
|
8
|
-
<meta
|
|
9
|
-
name="description"
|
|
10
|
-
content="Web site created using create-react-app"
|
|
11
|
-
/>
|
|
12
|
-
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
|
13
|
-
<!--
|
|
14
|
-
manifest.json provides metadata used when your web app is installed on a
|
|
15
|
-
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
|
16
|
-
-->
|
|
17
|
-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
|
18
|
-
<!--
|
|
19
|
-
Notice the use of %PUBLIC_URL% in the tags above.
|
|
20
|
-
It will be replaced with the URL of the `public` folder during the build.
|
|
21
|
-
Only files inside the `public` folder can be referenced from the HTML.
|
|
22
|
-
|
|
23
|
-
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
24
|
-
work correctly both with client-side routing and a non-root public URL.
|
|
25
|
-
Learn how to configure a non-root public URL by running `npm run build`.
|
|
26
|
-
-->
|
|
27
|
-
<title>React App</title>
|
|
28
|
-
</head>
|
|
29
|
-
<body>
|
|
30
|
-
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
31
|
-
<div id="root"></div>
|
|
32
|
-
<!--
|
|
33
|
-
This HTML file is a template.
|
|
34
|
-
If you open it directly in the browser, you will see an empty page.
|
|
35
|
-
|
|
36
|
-
You can add webfonts, meta tags, or analytics to this file.
|
|
37
|
-
The build step will place the bundled scripts into the <body> tag.
|
|
38
|
-
|
|
39
|
-
To begin the development, run `npm start` or `yarn start`.
|
|
40
|
-
To create a production bundle, use `npm run build` or `yarn build`.
|
|
41
|
-
-->
|
|
42
|
-
</body>
|
|
43
|
-
</html>
|
package/public/logo192.png
DELETED
|
Binary file
|
package/public/logo512.png
DELETED
|
Binary file
|
package/public/manifest.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"short_name": "React App",
|
|
3
|
-
"name": "Create React App Sample",
|
|
4
|
-
"icons": [
|
|
5
|
-
{
|
|
6
|
-
"src": "favicon.ico",
|
|
7
|
-
"sizes": "64x64 32x32 24x24 16x16",
|
|
8
|
-
"type": "image/x-icon"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"src": "logo192.png",
|
|
12
|
-
"type": "image/png",
|
|
13
|
-
"sizes": "192x192"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"src": "logo512.png",
|
|
17
|
-
"type": "image/png",
|
|
18
|
-
"sizes": "512x512"
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
"start_url": ".",
|
|
22
|
-
"display": "standalone",
|
|
23
|
-
"theme_color": "#000000",
|
|
24
|
-
"background_color": "#ffffff"
|
|
25
|
-
}
|
package/public/robots.txt
DELETED
package/src/App.css
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/* .App {
|
|
2
|
-
text-align: center;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.App-logo {
|
|
6
|
-
height: 40vmin;
|
|
7
|
-
pointer-events: none;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
@media (prefers-reduced-motion: no-preference) {
|
|
11
|
-
.App-logo {
|
|
12
|
-
animation: App-logo-spin infinite 20s linear;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.App-header {
|
|
17
|
-
background-color: #282c34;
|
|
18
|
-
min-height: 100vh;
|
|
19
|
-
display: flex;
|
|
20
|
-
flex-direction: column;
|
|
21
|
-
align-items: center;
|
|
22
|
-
justify-content: center;
|
|
23
|
-
font-size: calc(10px + 2vmin);
|
|
24
|
-
color: white;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.App-link {
|
|
28
|
-
color: #61dafb;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@keyframes App-logo-spin {
|
|
32
|
-
from {
|
|
33
|
-
transform: rotate(0deg);
|
|
34
|
-
}
|
|
35
|
-
to {
|
|
36
|
-
transform: rotate(360deg);
|
|
37
|
-
}
|
|
38
|
-
} */
|
package/src/App.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from "react";
|
|
2
|
-
|
|
3
|
-
// Note: Bootstrap is not really used.
|
|
4
|
-
// Just the default css is loaded to test how the component works with bootstrap.
|
|
5
|
-
import "bootstrap/dist/css/bootstrap.min.css";
|
|
6
|
-
|
|
7
|
-
import "./App.css";
|
|
8
|
-
import StructureVisualizer from "./StructureVisualizer";
|
|
9
|
-
|
|
10
|
-
async function fetchCif() {
|
|
11
|
-
// Fetch a cif file from the Materials Cloud AiiDA rest api
|
|
12
|
-
const aiidaRestEndpoint = "https://aiida.materialscloud.org/mc3d/api/v4";
|
|
13
|
-
const uuid = "85260507-9cb4-4849-a10d-703f32697dd7";
|
|
14
|
-
|
|
15
|
-
const responseAiiDACif = await fetch(
|
|
16
|
-
`${aiidaRestEndpoint}/nodes/${uuid}/download?download_format=cif&download=false`
|
|
17
|
-
);
|
|
18
|
-
const jsonAiiDACif = await responseAiiDACif.json();
|
|
19
|
-
|
|
20
|
-
return jsonAiiDACif.data.download.data;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function App() {
|
|
24
|
-
const [cifText, setCifText] = useState(null);
|
|
25
|
-
|
|
26
|
-
// componentDidMount equivalent
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
fetchCif().then((cifText) => {
|
|
29
|
-
setCifText(cifText);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<div className="App">
|
|
35
|
-
<StructureVisualizer cifText={cifText} />
|
|
36
|
-
</div>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export default App;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
.control-box {
|
|
2
|
-
position: relative;
|
|
3
|
-
z-index: 1;
|
|
4
|
-
height: 100px;
|
|
5
|
-
width: 450px;
|
|
6
|
-
background: rgb(250, 250, 250);
|
|
7
|
-
text-align: center;
|
|
8
|
-
border: 1px solid #999;
|
|
9
|
-
display: flex;
|
|
10
|
-
flex-direction: column;
|
|
11
|
-
justify-content: center;
|
|
12
|
-
align-items: start;
|
|
13
|
-
margin-top: -20px;
|
|
14
|
-
padding: 30px 10px 10px 10px;
|
|
15
|
-
border-radius: 5px;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.supercell-input {
|
|
19
|
-
width: 45px;
|
|
20
|
-
height: 25px;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/* Always show the small arrows (needed for Chrome) */
|
|
24
|
-
.supercell-input::-webkit-inner-spin-button,
|
|
25
|
-
.supercell-input::-webkit-outer-spin-button {
|
|
26
|
-
opacity: 1;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.control-box-row {
|
|
30
|
-
margin: 5px 0px;
|
|
31
|
-
padding: 0px 10px;
|
|
32
|
-
width: 100%;
|
|
33
|
-
line-height: inherit;
|
|
34
|
-
/* background-color: pink; */
|
|
35
|
-
display: flex;
|
|
36
|
-
justify-content: space-between;
|
|
37
|
-
align-items: stretch;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.control-box-row label {
|
|
41
|
-
margin: 0px 5px;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.control-box-row button {
|
|
45
|
-
border-width: 1px;
|
|
46
|
-
border-style: outset;
|
|
47
|
-
border-color: rgb(0, 0, 0);
|
|
48
|
-
border-radius: 4px;
|
|
49
|
-
display: inline-flex;
|
|
50
|
-
align-items: center;
|
|
51
|
-
/* margin-top: -10px; */
|
|
52
|
-
margin: 0px 1px;
|
|
53
|
-
height: 25px;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.control-box-row button:hover {
|
|
57
|
-
background-color: rgb(222, 222, 222);
|
|
58
|
-
}
|
|
59
|
-
.control-box-row .option-checkbox {
|
|
60
|
-
margin: 0px 2px;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.control-box-row .camera-controls {
|
|
64
|
-
margin-left: auto;
|
|
65
|
-
margin-right: auto;
|
|
66
|
-
display: inline;
|
|
67
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import "./index.css";
|
|
4
|
-
|
|
5
|
-
class ControlBox extends React.Component {
|
|
6
|
-
constructor(props) {
|
|
7
|
-
super(props);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
handleSupercellChange = (index, value) => {
|
|
11
|
-
let newSupercell = this.props.viewerParams.supercell;
|
|
12
|
-
newSupercell[index] = parseInt(value);
|
|
13
|
-
this.props.onViewerParamChange("supercell", newSupercell);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
handleOptionChange = (option) => {
|
|
17
|
-
this.props.onViewerParamChange(option, !this.props.viewerParams[option]);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
handleCameraEvent = (orientation) => {
|
|
21
|
-
this.props.onViewerEvent("camera", orientation);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
render() {
|
|
25
|
-
return (
|
|
26
|
-
<div className="control-box">
|
|
27
|
-
<div className="control-box-row">
|
|
28
|
-
<div className="supercell-container">
|
|
29
|
-
<label>Supercell: </label>
|
|
30
|
-
{[0, 1, 2].map((index) => (
|
|
31
|
-
<input
|
|
32
|
-
key={index}
|
|
33
|
-
className="supercell-input"
|
|
34
|
-
type="number"
|
|
35
|
-
min="1"
|
|
36
|
-
value={this.props.viewerParams.supercell[index]}
|
|
37
|
-
onChange={(e) =>
|
|
38
|
-
this.handleSupercellChange(index, e.target.value)
|
|
39
|
-
}
|
|
40
|
-
/>
|
|
41
|
-
))}
|
|
42
|
-
</div>
|
|
43
|
-
<div className="camera-controls">
|
|
44
|
-
<label>Camera: </label>
|
|
45
|
-
<button onClick={() => this.handleCameraEvent("x")}>x</button>
|
|
46
|
-
<button onClick={() => this.handleCameraEvent("y")}>y</button>
|
|
47
|
-
<button onClick={() => this.handleCameraEvent("z")}>z</button>
|
|
48
|
-
</div>
|
|
49
|
-
</div>
|
|
50
|
-
<div className="control-box-row">
|
|
51
|
-
<label>
|
|
52
|
-
<input
|
|
53
|
-
className="option-checkbox"
|
|
54
|
-
type="checkbox"
|
|
55
|
-
checked={this.props.viewerParams.bonds}
|
|
56
|
-
onChange={() => this.handleOptionChange("bonds")}
|
|
57
|
-
/>
|
|
58
|
-
Bonds
|
|
59
|
-
</label>
|
|
60
|
-
<label>
|
|
61
|
-
<input
|
|
62
|
-
className="option-checkbox"
|
|
63
|
-
type="checkbox"
|
|
64
|
-
checked={this.props.viewerParams.atomLabels}
|
|
65
|
-
onChange={() => this.handleOptionChange("atomLabels")}
|
|
66
|
-
/>
|
|
67
|
-
Atom labels
|
|
68
|
-
</label>
|
|
69
|
-
<label>
|
|
70
|
-
<input
|
|
71
|
-
className="option-checkbox"
|
|
72
|
-
type="checkbox"
|
|
73
|
-
checked={this.props.viewerParams.packedCell}
|
|
74
|
-
onChange={() => this.handleOptionChange("packedCell")}
|
|
75
|
-
disabled={true}
|
|
76
|
-
/>
|
|
77
|
-
Packed cell
|
|
78
|
-
</label>
|
|
79
|
-
<label>
|
|
80
|
-
<input
|
|
81
|
-
className="option-checkbox"
|
|
82
|
-
type="checkbox"
|
|
83
|
-
checked={this.props.viewerParams.spaceFilling}
|
|
84
|
-
onChange={() => this.handleOptionChange("vdwRadius")}
|
|
85
|
-
/>
|
|
86
|
-
vdW radius
|
|
87
|
-
</label>
|
|
88
|
-
</div>
|
|
89
|
-
</div>
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export default ControlBox;
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import * as $3Dmol from "3dmol";
|
|
4
|
-
|
|
5
|
-
import "./Visualizer3dmol.css";
|
|
6
|
-
import { isLabelWithInternallyDisabledControl } from "@testing-library/user-event/dist/utils";
|
|
7
|
-
|
|
8
|
-
class Visualizer3dmol extends React.Component {
|
|
9
|
-
constructor(props) {
|
|
10
|
-
super(props);
|
|
11
|
-
|
|
12
|
-
this.viewer = null;
|
|
13
|
-
this.model = null;
|
|
14
|
-
|
|
15
|
-
// Assign random id to prevent multiple 'gldiv' from clashing
|
|
16
|
-
this.divId = "gldiv-" + (Math.random() + 1).toString(36).substring(7);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
componentDidMount() {
|
|
20
|
-
// set up the viewer instance
|
|
21
|
-
let config = { backgroundColor: "white", orthographic: true };
|
|
22
|
-
this.viewer = $3Dmol.createViewer(this.divId, config);
|
|
23
|
-
|
|
24
|
-
this.updateView();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
componentDidUpdate(prevProps) {
|
|
28
|
-
if (
|
|
29
|
-
prevProps.viewerParams != this.props.viewerParams ||
|
|
30
|
-
prevProps.cifText != this.props.cifText
|
|
31
|
-
) {
|
|
32
|
-
this.updateView();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
updateView() {
|
|
37
|
-
this.viewer.removeAllModels();
|
|
38
|
-
this.model = this.viewer.addModel(this.props.cifText, "cif");
|
|
39
|
-
|
|
40
|
-
let style = {
|
|
41
|
-
sphere: { scale: 0.3, colorscheme: "Jmol" },
|
|
42
|
-
};
|
|
43
|
-
if (this.props.viewerParams.vdwRadius) {
|
|
44
|
-
style.sphere.scale = 1.0;
|
|
45
|
-
}
|
|
46
|
-
if (this.props.viewerParams.bonds) {
|
|
47
|
-
style.stick = { radius: 0.2, colorscheme: "Jmol" };
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
this.viewer.setStyle(style);
|
|
51
|
-
|
|
52
|
-
this.viewer.addUnitCell(this.model);
|
|
53
|
-
let sc = this.props.viewerParams.supercell;
|
|
54
|
-
this.viewer.replicateUnitCell(sc[0], sc[1], sc[2], this.model);
|
|
55
|
-
|
|
56
|
-
this.model.assignBonds();
|
|
57
|
-
|
|
58
|
-
this.viewer.removeAllLabels();
|
|
59
|
-
if (this.props.viewerParams.atomLabels) {
|
|
60
|
-
this.model.atoms.forEach((atom) => {
|
|
61
|
-
this.viewer.addLabel(
|
|
62
|
-
atom.elem,
|
|
63
|
-
{
|
|
64
|
-
position: { x: atom.x, y: atom.y, z: atom.z },
|
|
65
|
-
fontColor: atom.color,
|
|
66
|
-
fontSize: 18,
|
|
67
|
-
showBackground: false,
|
|
68
|
-
backgroundOpacity: 0.5,
|
|
69
|
-
inFront: false,
|
|
70
|
-
},
|
|
71
|
-
null,
|
|
72
|
-
true
|
|
73
|
-
);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
this.viewer.zoomTo();
|
|
78
|
-
this.viewer.zoom(1.4);
|
|
79
|
-
this.viewer.render();
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
handleEvent(type, value) {
|
|
83
|
-
if (type == "camera") {
|
|
84
|
-
// console.log(this.viewer.getView());
|
|
85
|
-
if (value == "x") {
|
|
86
|
-
this.viewer.setView([0.0, 0.0, 0.0, 0.0, -0.5, -0.5, -0.5, 0.5]);
|
|
87
|
-
}
|
|
88
|
-
if (value == "y") {
|
|
89
|
-
this.viewer.setView([0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5]);
|
|
90
|
-
}
|
|
91
|
-
if (value == "z") {
|
|
92
|
-
this.viewer.setView([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0]);
|
|
93
|
-
}
|
|
94
|
-
this.viewer.zoomTo();
|
|
95
|
-
this.viewer.zoom(1.4);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
render() {
|
|
100
|
-
return (
|
|
101
|
-
<div id={this.divId} className="gldiv">
|
|
102
|
-
No data!
|
|
103
|
-
</div>
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export default Visualizer3dmol;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
.structure-window-outer {
|
|
2
|
-
position: relative;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.structure-window {
|
|
6
|
-
position: relative;
|
|
7
|
-
z-index: 2;
|
|
8
|
-
height: 370px;
|
|
9
|
-
width: 450px;
|
|
10
|
-
background: white;
|
|
11
|
-
text-align: center;
|
|
12
|
-
border: 1px solid #999;
|
|
13
|
-
display: flex;
|
|
14
|
-
justify-content: center;
|
|
15
|
-
align-items: center;
|
|
16
|
-
border-radius: 5px;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.disable-mouse {
|
|
20
|
-
pointer-events: none;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.mouse-disabled-note {
|
|
24
|
-
background-color: #fff1f1;
|
|
25
|
-
border: 1px solid black;
|
|
26
|
-
color: #353434;
|
|
27
|
-
padding: 2px 6px;
|
|
28
|
-
border-radius: 5px;
|
|
29
|
-
position: absolute;
|
|
30
|
-
top: 10px;
|
|
31
|
-
left: 10px;
|
|
32
|
-
z-index: 3;
|
|
33
|
-
cursor: pointer;
|
|
34
|
-
user-select: none;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.on {
|
|
38
|
-
background-color: #e9ffe7;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.mouse-disabled-note:hover {
|
|
42
|
-
filter: brightness(90%);
|
|
43
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import Visualizer3dmol from "./3dmol/Visualizer3dmol";
|
|
4
|
-
|
|
5
|
-
import "./index.css";
|
|
6
|
-
|
|
7
|
-
class StructureWindow extends React.Component {
|
|
8
|
-
constructor(props) {
|
|
9
|
-
super(props);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
render() {
|
|
13
|
-
let swClassName = "structure-window";
|
|
14
|
-
if (!this.props.mouseEnabled) swClassName += " disable-mouse";
|
|
15
|
-
|
|
16
|
-
let mouseNoteText = "Interaction off";
|
|
17
|
-
let mouseNoteClass = "mouse-disabled-note";
|
|
18
|
-
if (this.props.mouseEnabled) {
|
|
19
|
-
mouseNoteText = "Interaction on";
|
|
20
|
-
mouseNoteClass = "mouse-disabled-note on";
|
|
21
|
-
}
|
|
22
|
-
return (
|
|
23
|
-
<div className="structure-window-outer">
|
|
24
|
-
<div onClick={() => this.props.setMouseEnabledState(true)}>
|
|
25
|
-
<div className={swClassName}>
|
|
26
|
-
<Visualizer3dmol
|
|
27
|
-
ref={this.props.visualizerRef}
|
|
28
|
-
viewerParams={this.props.viewerParams}
|
|
29
|
-
cifText={this.props.cifText}
|
|
30
|
-
/>
|
|
31
|
-
</div>
|
|
32
|
-
</div>
|
|
33
|
-
<div
|
|
34
|
-
className={mouseNoteClass}
|
|
35
|
-
onClick={() =>
|
|
36
|
-
this.props.setMouseEnabledState(!this.props.mouseEnabled)
|
|
37
|
-
}
|
|
38
|
-
>
|
|
39
|
-
{mouseNoteText}
|
|
40
|
-
</div>
|
|
41
|
-
</div>
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export default StructureWindow;
|