mc-react-structure-visualizer 0.3.0 → 0.4.1
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 +16 -3
- package/dist/ControlBox/index.js +21 -19
- package/dist/{3dmol → StructureWindow/3dmol}/Visualizer3dmol.js +35 -14
- package/dist/StructureWindow/index.css +43 -0
- package/dist/StructureWindow/index.js +65 -0
- package/dist/index.css +1 -11
- package/dist/index.js +47 -16
- package/package.json +5 -3
- 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 +0 -2
- package/src/StructureVisualizer/ControlBox/index.css +16 -3
- package/src/StructureVisualizer/ControlBox/index.js +17 -15
- package/src/StructureVisualizer/{3dmol → StructureWindow/3dmol}/Visualizer3dmol.js +32 -6
- package/src/StructureVisualizer/StructureWindow/index.css +43 -0
- package/src/StructureVisualizer/StructureWindow/index.js +49 -0
- package/src/StructureVisualizer/index.css +1 -11
- 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/dist/{3dmol → StructureWindow/3dmol}/Visualizer3dmol.css +0 -0
- /package/src/StructureVisualizer/{3dmol → StructureWindow/3dmol}/Visualizer3dmol.css +0 -0
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)
|
|
@@ -16,13 +16,25 @@
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
.supercell-input {
|
|
19
|
-
width:
|
|
19
|
+
width: 45px;
|
|
20
20
|
height: 25px;
|
|
21
21
|
}
|
|
22
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
|
+
|
|
23
29
|
.control-box-row {
|
|
24
|
-
margin: 5px
|
|
30
|
+
margin: 5px 0px;
|
|
31
|
+
padding: 0px 10px;
|
|
32
|
+
width: 100%;
|
|
25
33
|
line-height: inherit;
|
|
34
|
+
/* background-color: pink; */
|
|
35
|
+
display: flex;
|
|
36
|
+
justify-content: space-between;
|
|
37
|
+
align-items: stretch;
|
|
26
38
|
}
|
|
27
39
|
|
|
28
40
|
.control-box-row label {
|
|
@@ -49,6 +61,7 @@
|
|
|
49
61
|
}
|
|
50
62
|
|
|
51
63
|
.control-box-row .camera-controls {
|
|
52
|
-
margin:
|
|
64
|
+
margin-left: auto;
|
|
65
|
+
margin-right: auto;
|
|
53
66
|
display: inline;
|
|
54
67
|
}
|
package/dist/ControlBox/index.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports["default"] = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
require("./index.css");
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
10
|
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); }
|
|
11
11
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
12
|
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); } }
|
|
@@ -45,52 +45,54 @@ var ControlBox = /*#__PURE__*/function (_React$Component) {
|
|
|
45
45
|
key: "render",
|
|
46
46
|
value: function render() {
|
|
47
47
|
var _this2 = this;
|
|
48
|
-
return /*#__PURE__*/_react
|
|
48
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
49
49
|
className: "control-box"
|
|
50
|
-
}, /*#__PURE__*/_react
|
|
50
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
51
51
|
className: "control-box-row"
|
|
52
|
-
}, /*#__PURE__*/_react
|
|
53
|
-
|
|
52
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
53
|
+
className: "supercell-container"
|
|
54
|
+
}, /*#__PURE__*/_react["default"].createElement("label", null, "Supercell: "), [0, 1, 2].map(function (index) {
|
|
55
|
+
return /*#__PURE__*/_react["default"].createElement("input", {
|
|
54
56
|
key: index,
|
|
55
57
|
className: "supercell-input",
|
|
56
58
|
type: "number",
|
|
59
|
+
min: "1",
|
|
57
60
|
value: _this2.props.viewerParams.supercell[index],
|
|
58
61
|
onChange: function onChange(e) {
|
|
59
62
|
return _this2.handleSupercellChange(index, e.target.value);
|
|
60
63
|
}
|
|
61
64
|
});
|
|
62
|
-
}), /*#__PURE__*/_react
|
|
65
|
+
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
63
66
|
className: "camera-controls"
|
|
64
|
-
}, /*#__PURE__*/_react
|
|
67
|
+
}, /*#__PURE__*/_react["default"].createElement("label", null, "Camera: "), /*#__PURE__*/_react["default"].createElement("button", {
|
|
65
68
|
onClick: function onClick() {
|
|
66
69
|
return _this2.handleCameraEvent("x");
|
|
67
70
|
}
|
|
68
|
-
}, "x"), /*#__PURE__*/_react
|
|
71
|
+
}, "x"), /*#__PURE__*/_react["default"].createElement("button", {
|
|
69
72
|
onClick: function onClick() {
|
|
70
73
|
return _this2.handleCameraEvent("y");
|
|
71
74
|
}
|
|
72
|
-
}, "y"), /*#__PURE__*/_react
|
|
75
|
+
}, "y"), /*#__PURE__*/_react["default"].createElement("button", {
|
|
73
76
|
onClick: function onClick() {
|
|
74
77
|
return _this2.handleCameraEvent("z");
|
|
75
78
|
}
|
|
76
|
-
}, "z"))), /*#__PURE__*/_react
|
|
79
|
+
}, "z"))), /*#__PURE__*/_react["default"].createElement("div", {
|
|
77
80
|
className: "control-box-row"
|
|
78
|
-
}, /*#__PURE__*/_react
|
|
81
|
+
}, /*#__PURE__*/_react["default"].createElement("label", null, /*#__PURE__*/_react["default"].createElement("input", {
|
|
79
82
|
className: "option-checkbox",
|
|
80
83
|
type: "checkbox",
|
|
81
84
|
checked: this.props.viewerParams.bonds,
|
|
82
85
|
onChange: function onChange() {
|
|
83
86
|
return _this2.handleOptionChange("bonds");
|
|
84
87
|
}
|
|
85
|
-
}), "Bonds"), /*#__PURE__*/_react
|
|
88
|
+
}), "Bonds"), /*#__PURE__*/_react["default"].createElement("label", null, /*#__PURE__*/_react["default"].createElement("input", {
|
|
86
89
|
className: "option-checkbox",
|
|
87
90
|
type: "checkbox",
|
|
88
91
|
checked: this.props.viewerParams.atomLabels,
|
|
89
92
|
onChange: function onChange() {
|
|
90
93
|
return _this2.handleOptionChange("atomLabels");
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
}), "Atom Labels"), /*#__PURE__*/_react.default.createElement("label", null, /*#__PURE__*/_react.default.createElement("input", {
|
|
94
|
+
}
|
|
95
|
+
}), "Atom labels"), /*#__PURE__*/_react["default"].createElement("label", null, /*#__PURE__*/_react["default"].createElement("input", {
|
|
94
96
|
className: "option-checkbox",
|
|
95
97
|
type: "checkbox",
|
|
96
98
|
checked: this.props.viewerParams.packedCell,
|
|
@@ -98,7 +100,7 @@ var ControlBox = /*#__PURE__*/function (_React$Component) {
|
|
|
98
100
|
return _this2.handleOptionChange("packedCell");
|
|
99
101
|
},
|
|
100
102
|
disabled: true
|
|
101
|
-
}), "Packed
|
|
103
|
+
}), "Packed cell"), /*#__PURE__*/_react["default"].createElement("label", null, /*#__PURE__*/_react["default"].createElement("input", {
|
|
102
104
|
className: "option-checkbox",
|
|
103
105
|
type: "checkbox",
|
|
104
106
|
checked: this.props.viewerParams.spaceFilling,
|
|
@@ -109,6 +111,6 @@ var ControlBox = /*#__PURE__*/function (_React$Component) {
|
|
|
109
111
|
}
|
|
110
112
|
}]);
|
|
111
113
|
return ControlBox;
|
|
112
|
-
}(_react
|
|
114
|
+
}(_react["default"].Component);
|
|
113
115
|
var _default = ControlBox;
|
|
114
|
-
exports
|
|
116
|
+
exports["default"] = _default;
|
|
@@ -4,13 +4,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports
|
|
7
|
+
exports["default"] = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var $3Dmol = _interopRequireWildcard(require("3dmol"));
|
|
10
10
|
require("./Visualizer3dmol.css");
|
|
11
|
+
var _utils = require("@testing-library/user-event/dist/utils");
|
|
11
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
15
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
16
|
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); } }
|
|
16
17
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -42,15 +43,23 @@ var Visualizer3dmol = /*#__PURE__*/function (_React$Component) {
|
|
|
42
43
|
value: function componentDidMount() {
|
|
43
44
|
// set up the viewer instance
|
|
44
45
|
var config = {
|
|
45
|
-
backgroundColor: "
|
|
46
|
+
backgroundColor: "white",
|
|
46
47
|
orthographic: true
|
|
47
48
|
};
|
|
48
49
|
this.viewer = $3Dmol.createViewer(this.divId, config);
|
|
49
50
|
this.updateView();
|
|
50
51
|
}
|
|
52
|
+
}, {
|
|
53
|
+
key: "componentDidUpdate",
|
|
54
|
+
value: function componentDidUpdate(prevProps) {
|
|
55
|
+
if (prevProps.viewerParams != this.props.viewerParams || prevProps.cifText != this.props.cifText) {
|
|
56
|
+
this.updateView();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
51
59
|
}, {
|
|
52
60
|
key: "updateView",
|
|
53
61
|
value: function updateView() {
|
|
62
|
+
var _this2 = this;
|
|
54
63
|
this.viewer.removeAllModels();
|
|
55
64
|
this.model = this.viewer.addModel(this.props.cifText, "cif");
|
|
56
65
|
var style = {
|
|
@@ -73,11 +82,25 @@ var Visualizer3dmol = /*#__PURE__*/function (_React$Component) {
|
|
|
73
82
|
var sc = this.props.viewerParams.supercell;
|
|
74
83
|
this.viewer.replicateUnitCell(sc[0], sc[1], sc[2], this.model);
|
|
75
84
|
this.model.assignBonds();
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
85
|
+
this.viewer.removeAllLabels();
|
|
86
|
+
if (this.props.viewerParams.atomLabels) {
|
|
87
|
+
this.model.atoms.forEach(function (atom) {
|
|
88
|
+
_this2.viewer.addLabel(atom.elem, {
|
|
89
|
+
position: {
|
|
90
|
+
x: atom.x,
|
|
91
|
+
y: atom.y,
|
|
92
|
+
z: atom.z
|
|
93
|
+
},
|
|
94
|
+
fontColor: atom.color,
|
|
95
|
+
fontSize: 18,
|
|
96
|
+
showBackground: false,
|
|
97
|
+
backgroundOpacity: 0.5,
|
|
98
|
+
inFront: false
|
|
99
|
+
}, null, true);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
80
102
|
this.viewer.zoomTo();
|
|
103
|
+
this.viewer.zoom(1.4);
|
|
81
104
|
this.viewer.render();
|
|
82
105
|
}
|
|
83
106
|
}, {
|
|
@@ -95,21 +118,19 @@ var Visualizer3dmol = /*#__PURE__*/function (_React$Component) {
|
|
|
95
118
|
this.viewer.setView([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0]);
|
|
96
119
|
}
|
|
97
120
|
this.viewer.zoomTo();
|
|
121
|
+
this.viewer.zoom(1.4);
|
|
98
122
|
}
|
|
99
123
|
}
|
|
100
124
|
}, {
|
|
101
125
|
key: "render",
|
|
102
126
|
value: function render() {
|
|
103
|
-
|
|
104
|
-
this.updateView();
|
|
105
|
-
}
|
|
106
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
127
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
107
128
|
id: this.divId,
|
|
108
129
|
className: "gldiv"
|
|
109
130
|
}, "No data!");
|
|
110
131
|
}
|
|
111
132
|
}]);
|
|
112
133
|
return Visualizer3dmol;
|
|
113
|
-
}(_react
|
|
134
|
+
}(_react["default"].Component);
|
|
114
135
|
var _default = Visualizer3dmol;
|
|
115
|
-
exports
|
|
136
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
var mouseNoteText = "Interaction off";
|
|
38
|
+
var mouseNoteClass = "mouse-disabled-note";
|
|
39
|
+
if (this.props.mouseEnabled) {
|
|
40
|
+
mouseNoteText = "Interaction on";
|
|
41
|
+
mouseNoteClass = "mouse-disabled-note on";
|
|
42
|
+
}
|
|
43
|
+
return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
44
|
+
className: "structure-window-outer",
|
|
45
|
+
onClick: function onClick() {
|
|
46
|
+
return _this.props.setMouseEnabledState(true);
|
|
47
|
+
}
|
|
48
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
49
|
+
className: swClassName
|
|
50
|
+
}, /*#__PURE__*/_react["default"].createElement(_Visualizer3dmol["default"], {
|
|
51
|
+
ref: this.props.visualizerRef,
|
|
52
|
+
viewerParams: this.props.viewerParams,
|
|
53
|
+
cifText: this.props.cifText
|
|
54
|
+
}))), /*#__PURE__*/_react["default"].createElement("div", {
|
|
55
|
+
className: mouseNoteClass,
|
|
56
|
+
onClick: function onClick() {
|
|
57
|
+
return _this.props.setMouseEnabledState(!_this.props.mouseEnabled);
|
|
58
|
+
}
|
|
59
|
+
}, mouseNoteText));
|
|
60
|
+
}
|
|
61
|
+
}]);
|
|
62
|
+
return StructureWindow;
|
|
63
|
+
}(_react["default"].Component);
|
|
64
|
+
var _default = StructureWindow;
|
|
65
|
+
exports["default"] = _default;
|
package/dist/index.css
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
.structure-
|
|
2
|
-
position: relative;
|
|
3
|
-
z-index: 2;
|
|
4
|
-
height: 370px;
|
|
1
|
+
.structure-visualizer {
|
|
5
2
|
width: 450px;
|
|
6
|
-
background: #f5fffa;
|
|
7
|
-
text-align: center;
|
|
8
|
-
border: 1px solid #999;
|
|
9
|
-
display: flex;
|
|
10
|
-
justify-content: center;
|
|
11
|
-
align-items: center;
|
|
12
|
-
border-radius: 5px;
|
|
13
3
|
}
|
package/dist/index.js
CHANGED
|
@@ -4,12 +4,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports
|
|
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
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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; }
|
|
14
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
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; }
|
|
@@ -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
|
-
_this.visualizerRef = /*#__PURE__*/_react
|
|
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.setMouseEnabledState = _this.setMouseEnabledState.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: "setMouseEnabledState",
|
|
78
|
+
value: function setMouseEnabledState(state) {
|
|
79
|
+
this.setState({
|
|
80
|
+
mouseEnabled: state
|
|
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
|
-
|
|
68
|
-
|
|
98
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
99
|
+
ref: this.wrapperRef,
|
|
69
100
|
className: "structure-visualizer"
|
|
70
|
-
}, /*#__PURE__*/_react
|
|
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
|
+
setMouseEnabledState: this.setMouseEnabledState
|
|
107
|
+
}), /*#__PURE__*/_react["default"].createElement(_ControlBox["default"], {
|
|
77
108
|
viewerParams: this.state.viewerParams,
|
|
78
109
|
onViewerParamChange: this.handleViewerParamChange,
|
|
79
110
|
onViewerEvent: this.handleViewerEvent
|
|
@@ -81,6 +112,6 @@ var StructureVisualizer = /*#__PURE__*/function (_React$Component) {
|
|
|
81
112
|
}
|
|
82
113
|
}]);
|
|
83
114
|
return StructureVisualizer;
|
|
84
|
-
}(_react
|
|
115
|
+
}(_react["default"].Component);
|
|
85
116
|
var _default = StructureVisualizer;
|
|
86
|
-
exports
|
|
117
|
+
exports["default"] = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mc-react-structure-visualizer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"author": "Kristjan Eimre <kristjan.eimre@epfl.ch>",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"start": "react-scripts start",
|
|
27
|
-
"
|
|
27
|
+
"prebuild": "rimraf dist",
|
|
28
|
+
"build": "SET NODE_ENV=production && npx babel src/StructureVisualizer --out-dir dist --copy-files",
|
|
28
29
|
"test": "react-scripts test",
|
|
29
30
|
"eject": "react-scripts eject"
|
|
30
31
|
},
|
|
@@ -51,6 +52,7 @@
|
|
|
51
52
|
"@babel/core": "^7.20.12",
|
|
52
53
|
"@babel/preset-env": "^7.20.2",
|
|
53
54
|
"@babel/preset-react": "^7.18.6",
|
|
54
|
-
"babel-loader": "^9.1.2"
|
|
55
|
+
"babel-loader": "^9.1.2",
|
|
56
|
+
"rimraf": "^4.1.2"
|
|
55
57
|
}
|
|
56
58
|
}
|