mc-react-structure-visualizer 0.2.0 → 0.4.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 +74 -74
- package/dist/ControlBox/index.css +45 -10
- package/dist/ControlBox/index.js +8 -3
- package/dist/{3dmol → StructureWindow/3dmol}/Visualizer3dmol.css +0 -0
- package/dist/{3dmol → StructureWindow/3dmol}/Visualizer3dmol.js +7 -7
- package/dist/StructureWindow/index.css +33 -0
- package/dist/StructureWindow/index.js +56 -0
- package/dist/index.css +2 -13
- package/dist/index.js +41 -10
- package/package.json +3 -1
- package/public/index.html +43 -43
- package/public/manifest.json +25 -25
- package/public/robots.txt +3 -3
- package/src/App.css +38 -38
- package/src/App.js +4 -2
- package/src/StructureVisualizer/ControlBox/index.css +45 -10
- package/src/StructureVisualizer/ControlBox/index.js +11 -6
- package/src/StructureVisualizer/{3dmol → StructureWindow/3dmol}/Visualizer3dmol.css +0 -0
- package/src/StructureVisualizer/{3dmol → StructureWindow/3dmol}/Visualizer3dmol.js +9 -6
- package/src/StructureVisualizer/StructureWindow/index.css +33 -0
- package/src/StructureVisualizer/StructureWindow/index.js +35 -0
- package/src/StructureVisualizer/index.css +2 -13
- package/src/StructureVisualizer/index.js +33 -11
- package/src/index.css +13 -13
- package/src/index.js +17 -17
- package/src/reportWebVitals.js +13 -13
package/README.md
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
# React Materials Cloud Structure Visualizer
|
|
2
|
-
|
|
3
|
-
A React component to visualize structures on the Materials Cloud platform.
|
|
4
|
-
|
|
5
|
-
# Getting Started with Create React App
|
|
6
|
-
|
|
7
|
-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
|
8
|
-
|
|
9
|
-
## Available Scripts
|
|
10
|
-
|
|
11
|
-
In the project directory, you can run:
|
|
12
|
-
|
|
13
|
-
### `npm start`
|
|
14
|
-
|
|
15
|
-
Runs the app in the development mode.\
|
|
16
|
-
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
|
|
17
|
-
|
|
18
|
-
The page will reload when you make changes.\
|
|
19
|
-
You may also see any lint errors in the console.
|
|
20
|
-
|
|
21
|
-
### `npm test`
|
|
22
|
-
|
|
23
|
-
Launches the test runner in the interactive watch mode.\
|
|
24
|
-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
|
25
|
-
|
|
26
|
-
### `npm run build`
|
|
27
|
-
|
|
28
|
-
Builds the app for production to the `build` folder.\
|
|
29
|
-
It correctly bundles React in production mode and optimizes the build for the best performance.
|
|
30
|
-
|
|
31
|
-
The build is minified and the filenames include the hashes.\
|
|
32
|
-
Your app is ready to be deployed!
|
|
33
|
-
|
|
34
|
-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
|
35
|
-
|
|
36
|
-
### `npm run eject`
|
|
37
|
-
|
|
38
|
-
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
|
|
39
|
-
|
|
40
|
-
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
|
41
|
-
|
|
42
|
-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
|
|
43
|
-
|
|
44
|
-
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
|
|
45
|
-
|
|
46
|
-
## Learn More
|
|
47
|
-
|
|
48
|
-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
|
49
|
-
|
|
50
|
-
To learn React, check out the [React documentation](https://reactjs.org/).
|
|
51
|
-
|
|
52
|
-
### Code Splitting
|
|
53
|
-
|
|
54
|
-
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
|
|
55
|
-
|
|
56
|
-
### Analyzing the Bundle Size
|
|
57
|
-
|
|
58
|
-
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
|
|
59
|
-
|
|
60
|
-
### Making a Progressive Web App
|
|
61
|
-
|
|
62
|
-
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
|
|
63
|
-
|
|
64
|
-
### Advanced Configuration
|
|
65
|
-
|
|
66
|
-
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
|
|
67
|
-
|
|
68
|
-
### Deployment
|
|
69
|
-
|
|
70
|
-
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
|
|
71
|
-
|
|
72
|
-
### `npm run build` fails to minify
|
|
73
|
-
|
|
74
|
-
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
|
|
1
|
+
# React Materials Cloud Structure Visualizer
|
|
2
|
+
|
|
3
|
+
A React component to visualize structures on the Materials Cloud platform.
|
|
4
|
+
|
|
5
|
+
# Getting Started with Create React App
|
|
6
|
+
|
|
7
|
+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
|
8
|
+
|
|
9
|
+
## Available Scripts
|
|
10
|
+
|
|
11
|
+
In the project directory, you can run:
|
|
12
|
+
|
|
13
|
+
### `npm start`
|
|
14
|
+
|
|
15
|
+
Runs the app in the development mode.\
|
|
16
|
+
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
|
|
17
|
+
|
|
18
|
+
The page will reload when you make changes.\
|
|
19
|
+
You may also see any lint errors in the console.
|
|
20
|
+
|
|
21
|
+
### `npm test`
|
|
22
|
+
|
|
23
|
+
Launches the test runner in the interactive watch mode.\
|
|
24
|
+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
|
25
|
+
|
|
26
|
+
### `npm run build`
|
|
27
|
+
|
|
28
|
+
Builds the app for production to the `build` folder.\
|
|
29
|
+
It correctly bundles React in production mode and optimizes the build for the best performance.
|
|
30
|
+
|
|
31
|
+
The build is minified and the filenames include the hashes.\
|
|
32
|
+
Your app is ready to be deployed!
|
|
33
|
+
|
|
34
|
+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
|
35
|
+
|
|
36
|
+
### `npm run eject`
|
|
37
|
+
|
|
38
|
+
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
|
|
39
|
+
|
|
40
|
+
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
|
41
|
+
|
|
42
|
+
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
|
|
43
|
+
|
|
44
|
+
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
|
|
45
|
+
|
|
46
|
+
## Learn More
|
|
47
|
+
|
|
48
|
+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
|
49
|
+
|
|
50
|
+
To learn React, check out the [React documentation](https://reactjs.org/).
|
|
51
|
+
|
|
52
|
+
### Code Splitting
|
|
53
|
+
|
|
54
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
|
|
55
|
+
|
|
56
|
+
### Analyzing the Bundle Size
|
|
57
|
+
|
|
58
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
|
|
59
|
+
|
|
60
|
+
### Making a Progressive Web App
|
|
61
|
+
|
|
62
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
|
|
63
|
+
|
|
64
|
+
### Advanced Configuration
|
|
65
|
+
|
|
66
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
|
|
67
|
+
|
|
68
|
+
### Deployment
|
|
69
|
+
|
|
70
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
|
|
71
|
+
|
|
72
|
+
### `npm run build` fails to minify
|
|
73
|
+
|
|
74
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
|
|
@@ -1,25 +1,60 @@
|
|
|
1
1
|
.control-box {
|
|
2
2
|
position: relative;
|
|
3
3
|
z-index: 1;
|
|
4
|
-
height:
|
|
5
|
-
width:
|
|
6
|
-
background: rgb(
|
|
4
|
+
height: 100px;
|
|
5
|
+
width: 450px;
|
|
6
|
+
background: rgb(250, 250, 250);
|
|
7
7
|
text-align: center;
|
|
8
8
|
border: 1px solid #999;
|
|
9
9
|
display: flex;
|
|
10
10
|
flex-direction: column;
|
|
11
11
|
justify-content: center;
|
|
12
12
|
align-items: start;
|
|
13
|
-
margin:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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;
|
|
17
27
|
}
|
|
18
28
|
|
|
19
29
|
.control-box-row {
|
|
20
|
-
margin:
|
|
30
|
+
margin: 5px 5px;
|
|
31
|
+
line-height: inherit;
|
|
21
32
|
}
|
|
22
33
|
|
|
23
|
-
.
|
|
24
|
-
|
|
34
|
+
.control-box-row label {
|
|
35
|
+
margin: 0px 5px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.control-box-row button {
|
|
39
|
+
border-width: 1px;
|
|
40
|
+
border-style: outset;
|
|
41
|
+
border-color: rgb(0, 0, 0);
|
|
42
|
+
border-radius: 4px;
|
|
43
|
+
display: inline-flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
/* margin-top: -10px; */
|
|
46
|
+
margin: 0px 1px;
|
|
47
|
+
height: 25px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.control-box-row button:hover {
|
|
51
|
+
background-color: rgb(222, 222, 222);
|
|
52
|
+
}
|
|
53
|
+
.control-box-row .option-checkbox {
|
|
54
|
+
margin: 0px 2px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.control-box-row .camera-controls {
|
|
58
|
+
margin: 0px 30px;
|
|
59
|
+
display: inline;
|
|
25
60
|
}
|
package/dist/ControlBox/index.js
CHANGED
|
@@ -54,13 +54,14 @@ var ControlBox = /*#__PURE__*/function (_React$Component) {
|
|
|
54
54
|
key: index,
|
|
55
55
|
className: "supercell-input",
|
|
56
56
|
type: "number",
|
|
57
|
+
min: "1",
|
|
57
58
|
value: _this2.props.viewerParams.supercell[index],
|
|
58
59
|
onChange: function onChange(e) {
|
|
59
60
|
return _this2.handleSupercellChange(index, e.target.value);
|
|
60
61
|
}
|
|
61
62
|
});
|
|
62
|
-
})
|
|
63
|
-
className: "
|
|
63
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
64
|
+
className: "camera-controls"
|
|
64
65
|
}, /*#__PURE__*/_react.default.createElement("label", null, "Camera: "), /*#__PURE__*/_react.default.createElement("button", {
|
|
65
66
|
onClick: function onClick() {
|
|
66
67
|
return _this2.handleCameraEvent("x");
|
|
@@ -73,15 +74,17 @@ var ControlBox = /*#__PURE__*/function (_React$Component) {
|
|
|
73
74
|
onClick: function onClick() {
|
|
74
75
|
return _this2.handleCameraEvent("z");
|
|
75
76
|
}
|
|
76
|
-
}, "z")), /*#__PURE__*/_react.default.createElement("div", {
|
|
77
|
+
}, "z"))), /*#__PURE__*/_react.default.createElement("div", {
|
|
77
78
|
className: "control-box-row"
|
|
78
79
|
}, /*#__PURE__*/_react.default.createElement("label", null, /*#__PURE__*/_react.default.createElement("input", {
|
|
80
|
+
className: "option-checkbox",
|
|
79
81
|
type: "checkbox",
|
|
80
82
|
checked: this.props.viewerParams.bonds,
|
|
81
83
|
onChange: function onChange() {
|
|
82
84
|
return _this2.handleOptionChange("bonds");
|
|
83
85
|
}
|
|
84
86
|
}), "Bonds"), /*#__PURE__*/_react.default.createElement("label", null, /*#__PURE__*/_react.default.createElement("input", {
|
|
87
|
+
className: "option-checkbox",
|
|
85
88
|
type: "checkbox",
|
|
86
89
|
checked: this.props.viewerParams.atomLabels,
|
|
87
90
|
onChange: function onChange() {
|
|
@@ -89,6 +92,7 @@ var ControlBox = /*#__PURE__*/function (_React$Component) {
|
|
|
89
92
|
},
|
|
90
93
|
disabled: true
|
|
91
94
|
}), "Atom Labels"), /*#__PURE__*/_react.default.createElement("label", null, /*#__PURE__*/_react.default.createElement("input", {
|
|
95
|
+
className: "option-checkbox",
|
|
92
96
|
type: "checkbox",
|
|
93
97
|
checked: this.props.viewerParams.packedCell,
|
|
94
98
|
onChange: function onChange() {
|
|
@@ -96,6 +100,7 @@ var ControlBox = /*#__PURE__*/function (_React$Component) {
|
|
|
96
100
|
},
|
|
97
101
|
disabled: true
|
|
98
102
|
}), "Packed Cell"), /*#__PURE__*/_react.default.createElement("label", null, /*#__PURE__*/_react.default.createElement("input", {
|
|
103
|
+
className: "option-checkbox",
|
|
99
104
|
type: "checkbox",
|
|
100
105
|
checked: this.props.viewerParams.spaceFilling,
|
|
101
106
|
onChange: function onChange() {
|
|
File without changes
|
|
@@ -48,6 +48,13 @@ var Visualizer3dmol = /*#__PURE__*/function (_React$Component) {
|
|
|
48
48
|
this.viewer = $3Dmol.createViewer(this.divId, config);
|
|
49
49
|
this.updateView();
|
|
50
50
|
}
|
|
51
|
+
}, {
|
|
52
|
+
key: "componentDidUpdate",
|
|
53
|
+
value: function componentDidUpdate(prevProps) {
|
|
54
|
+
if (prevProps.viewerParams != this.props.viewerParams || prevProps.cifText != this.props.cifText) {
|
|
55
|
+
this.updateView();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
51
58
|
}, {
|
|
52
59
|
key: "updateView",
|
|
53
60
|
value: function updateView() {
|
|
@@ -73,10 +80,6 @@ var Visualizer3dmol = /*#__PURE__*/function (_React$Component) {
|
|
|
73
80
|
var sc = this.props.viewerParams.supercell;
|
|
74
81
|
this.viewer.replicateUnitCell(sc[0], sc[1], sc[2], this.model);
|
|
75
82
|
this.model.assignBonds();
|
|
76
|
-
|
|
77
|
-
// console.log(this.viewer.getView());
|
|
78
|
-
// this.viewer.setView([0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5]);
|
|
79
|
-
|
|
80
83
|
this.viewer.zoomTo();
|
|
81
84
|
this.viewer.render();
|
|
82
85
|
}
|
|
@@ -100,9 +103,6 @@ var Visualizer3dmol = /*#__PURE__*/function (_React$Component) {
|
|
|
100
103
|
}, {
|
|
101
104
|
key: "render",
|
|
102
105
|
value: function render() {
|
|
103
|
-
if (this.viewer && this.model) {
|
|
104
|
-
this.updateView();
|
|
105
|
-
}
|
|
106
106
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
107
107
|
id: this.divId,
|
|
108
108
|
className: "gldiv"
|
|
@@ -0,0 +1,33 @@
|
|
|
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: #f5fffa;
|
|
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: #fafafa;
|
|
25
|
+
border: 1px solid black;
|
|
26
|
+
color: #353434;
|
|
27
|
+
padding: 5px;
|
|
28
|
+
border-radius: 5px;
|
|
29
|
+
position: absolute;
|
|
30
|
+
top: 15px;
|
|
31
|
+
left: 170px;
|
|
32
|
+
z-index: 3;
|
|
33
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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 _Visualizer3dmol = _interopRequireDefault(require("./3dmol/Visualizer3dmol"));
|
|
10
|
+
require("./index.css");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
13
|
+
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); } }
|
|
14
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
15
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
16
|
+
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); }
|
|
17
|
+
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); }
|
|
18
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
19
|
+
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); }; }
|
|
20
|
+
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); }
|
|
21
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
22
|
+
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; } }
|
|
23
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
24
|
+
var StructureWindow = /*#__PURE__*/function (_React$Component) {
|
|
25
|
+
_inherits(StructureWindow, _React$Component);
|
|
26
|
+
var _super = _createSuper(StructureWindow);
|
|
27
|
+
function StructureWindow(props) {
|
|
28
|
+
_classCallCheck(this, StructureWindow);
|
|
29
|
+
return _super.call(this, props);
|
|
30
|
+
}
|
|
31
|
+
_createClass(StructureWindow, [{
|
|
32
|
+
key: "render",
|
|
33
|
+
value: function render() {
|
|
34
|
+
var _this = this;
|
|
35
|
+
var swClassName = "structure-window";
|
|
36
|
+
if (!this.props.mouseEnabled) swClassName += " disable-mouse";
|
|
37
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
38
|
+
className: "structure-window-outer",
|
|
39
|
+
onClick: function onClick() {
|
|
40
|
+
return _this.props.setMouseEnabled();
|
|
41
|
+
}
|
|
42
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
43
|
+
className: swClassName
|
|
44
|
+
}, /*#__PURE__*/_react.default.createElement(_Visualizer3dmol.default, {
|
|
45
|
+
ref: this.props.visualizerRef,
|
|
46
|
+
viewerParams: this.props.viewerParams,
|
|
47
|
+
cifText: this.props.cifText
|
|
48
|
+
})), !this.props.mouseEnabled && /*#__PURE__*/_react.default.createElement("div", {
|
|
49
|
+
className: "mouse-disabled-note"
|
|
50
|
+
}, "Click to interact!"));
|
|
51
|
+
}
|
|
52
|
+
}]);
|
|
53
|
+
return StructureWindow;
|
|
54
|
+
}(_react.default.Component);
|
|
55
|
+
var _default = StructureWindow;
|
|
56
|
+
exports.default = _default;
|
package/dist/index.css
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
.structure-
|
|
2
|
-
|
|
3
|
-
z-index: 2;
|
|
4
|
-
height: 350px;
|
|
5
|
-
width: 448px;
|
|
6
|
-
background: #f5fffa;
|
|
7
|
-
text-align: center;
|
|
8
|
-
border: 1px solid #999;
|
|
9
|
-
display: flex;
|
|
10
|
-
justify-content: center;
|
|
11
|
-
align-items: center;
|
|
12
|
-
margin: 3px;
|
|
13
|
-
border-radius: 10px;
|
|
1
|
+
.structure-visualizer {
|
|
2
|
+
width: 450px;
|
|
14
3
|
}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _ControlBox = _interopRequireDefault(require("./ControlBox"));
|
|
10
|
-
var
|
|
10
|
+
var _StructureWindow = _interopRequireDefault(require("./StructureWindow"));
|
|
11
11
|
require("./index.css");
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
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; }
|
|
@@ -35,21 +35,52 @@ var StructureVisualizer = /*#__PURE__*/function (_React$Component) {
|
|
|
35
35
|
_this.state = {
|
|
36
36
|
viewerParams: {
|
|
37
37
|
supercell: [2, 2, 2],
|
|
38
|
-
orientation: "x",
|
|
39
38
|
bonds: true,
|
|
40
39
|
atomLabels: false,
|
|
41
40
|
packedCell: false,
|
|
42
41
|
vdwRadius: false
|
|
43
|
-
}
|
|
42
|
+
},
|
|
43
|
+
mouseEnabled: false
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
// use Ref to send events to the visualizer backend
|
|
47
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));
|
|
48
52
|
_this.handleViewerParamChange = _this.handleViewerParamChange.bind(_assertThisInitialized(_this));
|
|
49
53
|
_this.handleViewerEvent = _this.handleViewerEvent.bind(_assertThisInitialized(_this));
|
|
54
|
+
_this.setMouseEnabled = _this.setMouseEnabled.bind(_assertThisInitialized(_this));
|
|
50
55
|
return _this;
|
|
51
56
|
}
|
|
52
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: "setMouseEnabled",
|
|
78
|
+
value: function setMouseEnabled() {
|
|
79
|
+
this.setState({
|
|
80
|
+
mouseEnabled: true
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
53
84
|
key: "handleViewerParamChange",
|
|
54
85
|
value: function handleViewerParamChange(param, value) {
|
|
55
86
|
this.setState({
|
|
@@ -64,16 +95,16 @@ var StructureVisualizer = /*#__PURE__*/function (_React$Component) {
|
|
|
64
95
|
}, {
|
|
65
96
|
key: "render",
|
|
66
97
|
value: function render() {
|
|
67
|
-
// console.log("CIF", this.props.cifText);
|
|
68
98
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
99
|
+
ref: this.wrapperRef,
|
|
69
100
|
className: "structure-visualizer"
|
|
70
|
-
}, /*#__PURE__*/_react.default.createElement(
|
|
71
|
-
|
|
72
|
-
}, /*#__PURE__*/_react.default.createElement(_Visualizer3dmol.default, {
|
|
73
|
-
ref: this.visualizerRef,
|
|
101
|
+
}, /*#__PURE__*/_react.default.createElement(_StructureWindow.default, {
|
|
102
|
+
visualizerRef: this.visualizerRef,
|
|
74
103
|
viewerParams: this.state.viewerParams,
|
|
75
|
-
cifText: this.props.cifText
|
|
76
|
-
|
|
104
|
+
cifText: this.props.cifText,
|
|
105
|
+
mouseEnabled: this.state.mouseEnabled,
|
|
106
|
+
setMouseEnabled: this.setMouseEnabled
|
|
107
|
+
}), /*#__PURE__*/_react.default.createElement(_ControlBox.default, {
|
|
77
108
|
viewerParams: this.state.viewerParams,
|
|
78
109
|
onViewerParamChange: this.handleViewerParamChange,
|
|
79
110
|
onViewerEvent: this.handleViewerEvent
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mc-react-structure-visualizer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"author": "Kristjan Eimre <kristjan.eimre@epfl.ch>",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
"@testing-library/react": "^13.4.0",
|
|
16
16
|
"@testing-library/user-event": "^13.5.0",
|
|
17
17
|
"3dmol": "^2.0.1",
|
|
18
|
+
"bootstrap": "^5.2.3",
|
|
18
19
|
"react": "^18.2.0",
|
|
20
|
+
"react-bootstrap": "^2.7.1",
|
|
19
21
|
"react-dom": "^18.2.0",
|
|
20
22
|
"react-scripts": "5.0.1",
|
|
21
23
|
"web-vitals": "^2.1.4"
|
package/public/index.html
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
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>
|
|
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/manifest.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
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
|
-
}
|
|
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
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# https://www.robotstxt.org/robotstxt.html
|
|
2
|
-
User-agent: *
|
|
3
|
-
Disallow:
|
|
1
|
+
# https://www.robotstxt.org/robotstxt.html
|
|
2
|
+
User-agent: *
|
|
3
|
+
Disallow:
|
package/src/App.css
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
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
|
-
} */
|
|
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
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import React, { useState, useEffect } from "react";
|
|
2
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
|
+
|
|
3
7
|
import "./App.css";
|
|
4
8
|
import StructureVisualizer from "./StructureVisualizer";
|
|
5
9
|
|
|
@@ -13,8 +17,6 @@ async function fetchCif() {
|
|
|
13
17
|
);
|
|
14
18
|
const jsonAiiDACif = await responseAiiDACif.json();
|
|
15
19
|
|
|
16
|
-
console.log(jsonAiiDACif);
|
|
17
|
-
|
|
18
20
|
return jsonAiiDACif.data.download.data;
|
|
19
21
|
}
|
|
20
22
|
|
|
@@ -1,25 +1,60 @@
|
|
|
1
1
|
.control-box {
|
|
2
2
|
position: relative;
|
|
3
3
|
z-index: 1;
|
|
4
|
-
height:
|
|
5
|
-
width:
|
|
6
|
-
background: rgb(
|
|
4
|
+
height: 100px;
|
|
5
|
+
width: 450px;
|
|
6
|
+
background: rgb(250, 250, 250);
|
|
7
7
|
text-align: center;
|
|
8
8
|
border: 1px solid #999;
|
|
9
9
|
display: flex;
|
|
10
10
|
flex-direction: column;
|
|
11
11
|
justify-content: center;
|
|
12
12
|
align-items: start;
|
|
13
|
-
margin:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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;
|
|
17
27
|
}
|
|
18
28
|
|
|
19
29
|
.control-box-row {
|
|
20
|
-
margin:
|
|
30
|
+
margin: 5px 5px;
|
|
31
|
+
line-height: inherit;
|
|
21
32
|
}
|
|
22
33
|
|
|
23
|
-
.
|
|
24
|
-
|
|
34
|
+
.control-box-row label {
|
|
35
|
+
margin: 0px 5px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.control-box-row button {
|
|
39
|
+
border-width: 1px;
|
|
40
|
+
border-style: outset;
|
|
41
|
+
border-color: rgb(0, 0, 0);
|
|
42
|
+
border-radius: 4px;
|
|
43
|
+
display: inline-flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
/* margin-top: -10px; */
|
|
46
|
+
margin: 0px 1px;
|
|
47
|
+
height: 25px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.control-box-row button:hover {
|
|
51
|
+
background-color: rgb(222, 222, 222);
|
|
52
|
+
}
|
|
53
|
+
.control-box-row .option-checkbox {
|
|
54
|
+
margin: 0px 2px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.control-box-row .camera-controls {
|
|
58
|
+
margin: 0px 30px;
|
|
59
|
+
display: inline;
|
|
25
60
|
}
|
|
@@ -31,22 +31,24 @@ class ControlBox extends React.Component {
|
|
|
31
31
|
key={index}
|
|
32
32
|
className="supercell-input"
|
|
33
33
|
type="number"
|
|
34
|
+
min="1"
|
|
34
35
|
value={this.props.viewerParams.supercell[index]}
|
|
35
36
|
onChange={(e) =>
|
|
36
37
|
this.handleSupercellChange(index, e.target.value)
|
|
37
38
|
}
|
|
38
39
|
/>
|
|
39
40
|
))}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
<div className="camera-controls">
|
|
42
|
+
<label>Camera: </label>
|
|
43
|
+
<button onClick={() => this.handleCameraEvent("x")}>x</button>
|
|
44
|
+
<button onClick={() => this.handleCameraEvent("y")}>y</button>
|
|
45
|
+
<button onClick={() => this.handleCameraEvent("z")}>z</button>
|
|
46
|
+
</div>
|
|
46
47
|
</div>
|
|
47
48
|
<div className="control-box-row">
|
|
48
49
|
<label>
|
|
49
50
|
<input
|
|
51
|
+
className="option-checkbox"
|
|
50
52
|
type="checkbox"
|
|
51
53
|
checked={this.props.viewerParams.bonds}
|
|
52
54
|
onChange={() => this.handleOptionChange("bonds")}
|
|
@@ -55,6 +57,7 @@ class ControlBox extends React.Component {
|
|
|
55
57
|
</label>
|
|
56
58
|
<label>
|
|
57
59
|
<input
|
|
60
|
+
className="option-checkbox"
|
|
58
61
|
type="checkbox"
|
|
59
62
|
checked={this.props.viewerParams.atomLabels}
|
|
60
63
|
onChange={() => this.handleOptionChange("atomLabels")}
|
|
@@ -64,6 +67,7 @@ class ControlBox extends React.Component {
|
|
|
64
67
|
</label>
|
|
65
68
|
<label>
|
|
66
69
|
<input
|
|
70
|
+
className="option-checkbox"
|
|
67
71
|
type="checkbox"
|
|
68
72
|
checked={this.props.viewerParams.packedCell}
|
|
69
73
|
onChange={() => this.handleOptionChange("packedCell")}
|
|
@@ -73,6 +77,7 @@ class ControlBox extends React.Component {
|
|
|
73
77
|
</label>
|
|
74
78
|
<label>
|
|
75
79
|
<input
|
|
80
|
+
className="option-checkbox"
|
|
76
81
|
type="checkbox"
|
|
77
82
|
checked={this.props.viewerParams.spaceFilling}
|
|
78
83
|
onChange={() => this.handleOptionChange("vdwRadius")}
|
|
File without changes
|
|
@@ -23,6 +23,15 @@ class Visualizer3dmol extends React.Component {
|
|
|
23
23
|
this.updateView();
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
componentDidUpdate(prevProps) {
|
|
27
|
+
if (
|
|
28
|
+
prevProps.viewerParams != this.props.viewerParams ||
|
|
29
|
+
prevProps.cifText != this.props.cifText
|
|
30
|
+
) {
|
|
31
|
+
this.updateView();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
26
35
|
updateView() {
|
|
27
36
|
this.viewer.removeAllModels();
|
|
28
37
|
this.model = this.viewer.addModel(this.props.cifText, "cif");
|
|
@@ -44,9 +53,6 @@ class Visualizer3dmol extends React.Component {
|
|
|
44
53
|
this.viewer.replicateUnitCell(sc[0], sc[1], sc[2], this.model);
|
|
45
54
|
this.model.assignBonds();
|
|
46
55
|
|
|
47
|
-
// console.log(this.viewer.getView());
|
|
48
|
-
// this.viewer.setView([0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5]);
|
|
49
|
-
|
|
50
56
|
this.viewer.zoomTo();
|
|
51
57
|
this.viewer.render();
|
|
52
58
|
}
|
|
@@ -68,9 +74,6 @@ class Visualizer3dmol extends React.Component {
|
|
|
68
74
|
}
|
|
69
75
|
|
|
70
76
|
render() {
|
|
71
|
-
if (this.viewer && this.model) {
|
|
72
|
-
this.updateView();
|
|
73
|
-
}
|
|
74
77
|
return (
|
|
75
78
|
<div id={this.divId} className="gldiv">
|
|
76
79
|
No data!
|
|
@@ -0,0 +1,33 @@
|
|
|
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: #f5fffa;
|
|
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: #fafafa;
|
|
25
|
+
border: 1px solid black;
|
|
26
|
+
color: #353434;
|
|
27
|
+
padding: 5px;
|
|
28
|
+
border-radius: 5px;
|
|
29
|
+
position: absolute;
|
|
30
|
+
top: 15px;
|
|
31
|
+
left: 170px;
|
|
32
|
+
z-index: 3;
|
|
33
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
return (
|
|
16
|
+
<div
|
|
17
|
+
className="structure-window-outer"
|
|
18
|
+
onClick={() => this.props.setMouseEnabled()}
|
|
19
|
+
>
|
|
20
|
+
<div className={swClassName}>
|
|
21
|
+
<Visualizer3dmol
|
|
22
|
+
ref={this.props.visualizerRef}
|
|
23
|
+
viewerParams={this.props.viewerParams}
|
|
24
|
+
cifText={this.props.cifText}
|
|
25
|
+
/>
|
|
26
|
+
</div>
|
|
27
|
+
{!this.props.mouseEnabled && (
|
|
28
|
+
<div className="mouse-disabled-note">Click to interact!</div>
|
|
29
|
+
)}
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default StructureWindow;
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
.structure-
|
|
2
|
-
|
|
3
|
-
z-index: 2;
|
|
4
|
-
height: 350px;
|
|
5
|
-
width: 448px;
|
|
6
|
-
background: #f5fffa;
|
|
7
|
-
text-align: center;
|
|
8
|
-
border: 1px solid #999;
|
|
9
|
-
display: flex;
|
|
10
|
-
justify-content: center;
|
|
11
|
-
align-items: center;
|
|
12
|
-
margin: 3px;
|
|
13
|
-
border-radius: 10px;
|
|
1
|
+
.structure-visualizer {
|
|
2
|
+
width: 450px;
|
|
14
3
|
}
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
|
|
3
3
|
import ControlBox from "./ControlBox";
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import StructureWindow from "./StructureWindow";
|
|
6
6
|
|
|
7
7
|
import "./index.css";
|
|
8
8
|
|
|
@@ -13,19 +13,42 @@ class StructureVisualizer extends React.Component {
|
|
|
13
13
|
this.state = {
|
|
14
14
|
viewerParams: {
|
|
15
15
|
supercell: [2, 2, 2],
|
|
16
|
-
orientation: "x",
|
|
17
16
|
bonds: true,
|
|
18
17
|
atomLabels: false,
|
|
19
18
|
packedCell: false,
|
|
20
19
|
vdwRadius: false,
|
|
21
20
|
},
|
|
21
|
+
mouseEnabled: false,
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
// use Ref to send events to the visualizer backend
|
|
25
25
|
this.visualizerRef = React.createRef();
|
|
26
26
|
|
|
27
|
+
// Ref to detect click outside
|
|
28
|
+
this.wrapperRef = React.createRef();
|
|
29
|
+
this.handleClickOutside = this.handleClickOutside.bind(this);
|
|
30
|
+
|
|
27
31
|
this.handleViewerParamChange = this.handleViewerParamChange.bind(this);
|
|
28
32
|
this.handleViewerEvent = this.handleViewerEvent.bind(this);
|
|
33
|
+
this.setMouseEnabled = this.setMouseEnabled.bind(this);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
componentDidMount() {
|
|
37
|
+
document.addEventListener("mousedown", this.handleClickOutside);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
componentWillUnmount() {
|
|
41
|
+
document.removeEventListener("mousedown", this.handleClickOutside);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
handleClickOutside(event) {
|
|
45
|
+
if (this.wrapperRef && !this.wrapperRef.current.contains(event.target)) {
|
|
46
|
+
this.setState({ mouseEnabled: false });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
setMouseEnabled() {
|
|
51
|
+
this.setState({ mouseEnabled: true });
|
|
29
52
|
}
|
|
30
53
|
|
|
31
54
|
handleViewerParamChange(param, value) {
|
|
@@ -42,16 +65,15 @@ class StructureVisualizer extends React.Component {
|
|
|
42
65
|
}
|
|
43
66
|
|
|
44
67
|
render() {
|
|
45
|
-
// console.log("CIF", this.props.cifText);
|
|
46
68
|
return (
|
|
47
|
-
<div className="structure-visualizer">
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
69
|
+
<div ref={this.wrapperRef} className="structure-visualizer">
|
|
70
|
+
<StructureWindow
|
|
71
|
+
visualizerRef={this.visualizerRef}
|
|
72
|
+
viewerParams={this.state.viewerParams}
|
|
73
|
+
cifText={this.props.cifText}
|
|
74
|
+
mouseEnabled={this.state.mouseEnabled}
|
|
75
|
+
setMouseEnabled={this.setMouseEnabled}
|
|
76
|
+
/>
|
|
55
77
|
<ControlBox
|
|
56
78
|
viewerParams={this.state.viewerParams}
|
|
57
79
|
onViewerParamChange={this.handleViewerParamChange}
|
package/src/index.css
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
body {
|
|
2
|
-
margin: 0;
|
|
3
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
|
4
|
-
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
|
5
|
-
sans-serif;
|
|
6
|
-
-webkit-font-smoothing: antialiased;
|
|
7
|
-
-moz-osx-font-smoothing: grayscale;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
code {
|
|
11
|
-
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
|
12
|
-
monospace;
|
|
13
|
-
}
|
|
1
|
+
body {
|
|
2
|
+
margin: 0;
|
|
3
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
|
4
|
+
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
|
5
|
+
sans-serif;
|
|
6
|
+
-webkit-font-smoothing: antialiased;
|
|
7
|
+
-moz-osx-font-smoothing: grayscale;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
code {
|
|
11
|
+
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
|
12
|
+
monospace;
|
|
13
|
+
}
|
package/src/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom/client';
|
|
3
|
-
import './index.css';
|
|
4
|
-
import App from './App';
|
|
5
|
-
import reportWebVitals from './reportWebVitals';
|
|
6
|
-
|
|
7
|
-
const root = ReactDOM.createRoot(document.getElementById('root'));
|
|
8
|
-
root.render(
|
|
9
|
-
<React.StrictMode>
|
|
10
|
-
<App />
|
|
11
|
-
</React.StrictMode>
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
// If you want to start measuring performance in your app, pass a function
|
|
15
|
-
// to log results (for example: reportWebVitals(console.log))
|
|
16
|
-
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
|
17
|
-
reportWebVitals();
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom/client';
|
|
3
|
+
import './index.css';
|
|
4
|
+
import App from './App';
|
|
5
|
+
import reportWebVitals from './reportWebVitals';
|
|
6
|
+
|
|
7
|
+
const root = ReactDOM.createRoot(document.getElementById('root'));
|
|
8
|
+
root.render(
|
|
9
|
+
<React.StrictMode>
|
|
10
|
+
<App />
|
|
11
|
+
</React.StrictMode>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
// If you want to start measuring performance in your app, pass a function
|
|
15
|
+
// to log results (for example: reportWebVitals(console.log))
|
|
16
|
+
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
|
17
|
+
reportWebVitals();
|
package/src/reportWebVitals.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const reportWebVitals = onPerfEntry => {
|
|
2
|
-
if (onPerfEntry && onPerfEntry instanceof Function) {
|
|
3
|
-
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
|
4
|
-
getCLS(onPerfEntry);
|
|
5
|
-
getFID(onPerfEntry);
|
|
6
|
-
getFCP(onPerfEntry);
|
|
7
|
-
getLCP(onPerfEntry);
|
|
8
|
-
getTTFB(onPerfEntry);
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default reportWebVitals;
|
|
1
|
+
const reportWebVitals = onPerfEntry => {
|
|
2
|
+
if (onPerfEntry && onPerfEntry instanceof Function) {
|
|
3
|
+
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
|
4
|
+
getCLS(onPerfEntry);
|
|
5
|
+
getFID(onPerfEntry);
|
|
6
|
+
getFCP(onPerfEntry);
|
|
7
|
+
getLCP(onPerfEntry);
|
|
8
|
+
getTTFB(onPerfEntry);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default reportWebVitals;
|