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/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
|
@@ -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
|
}
|
|
@@ -25,18 +25,21 @@ class ControlBox extends React.Component {
|
|
|
25
25
|
return (
|
|
26
26
|
<div className="control-box">
|
|
27
27
|
<div className="control-box-row">
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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>
|
|
40
43
|
<div className="camera-controls">
|
|
41
44
|
<label>Camera: </label>
|
|
42
45
|
<button onClick={() => this.handleCameraEvent("x")}>x</button>
|
|
@@ -60,9 +63,8 @@ class ControlBox extends React.Component {
|
|
|
60
63
|
type="checkbox"
|
|
61
64
|
checked={this.props.viewerParams.atomLabels}
|
|
62
65
|
onChange={() => this.handleOptionChange("atomLabels")}
|
|
63
|
-
disabled={true}
|
|
64
66
|
/>
|
|
65
|
-
Atom
|
|
67
|
+
Atom labels
|
|
66
68
|
</label>
|
|
67
69
|
<label>
|
|
68
70
|
<input
|
|
@@ -72,7 +74,7 @@ class ControlBox extends React.Component {
|
|
|
72
74
|
onChange={() => this.handleOptionChange("packedCell")}
|
|
73
75
|
disabled={true}
|
|
74
76
|
/>
|
|
75
|
-
Packed
|
|
77
|
+
Packed cell
|
|
76
78
|
</label>
|
|
77
79
|
<label>
|
|
78
80
|
<input
|
|
@@ -3,6 +3,7 @@ import React from "react";
|
|
|
3
3
|
import * as $3Dmol from "3dmol";
|
|
4
4
|
|
|
5
5
|
import "./Visualizer3dmol.css";
|
|
6
|
+
import { isLabelWithInternallyDisabledControl } from "@testing-library/user-event/dist/utils";
|
|
6
7
|
|
|
7
8
|
class Visualizer3dmol extends React.Component {
|
|
8
9
|
constructor(props) {
|
|
@@ -17,12 +18,21 @@ class Visualizer3dmol extends React.Component {
|
|
|
17
18
|
|
|
18
19
|
componentDidMount() {
|
|
19
20
|
// set up the viewer instance
|
|
20
|
-
let config = { backgroundColor: "
|
|
21
|
+
let config = { backgroundColor: "white", orthographic: true };
|
|
21
22
|
this.viewer = $3Dmol.createViewer(this.divId, config);
|
|
22
23
|
|
|
23
24
|
this.updateView();
|
|
24
25
|
}
|
|
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
|
+
|
|
26
36
|
updateView() {
|
|
27
37
|
this.viewer.removeAllModels();
|
|
28
38
|
this.model = this.viewer.addModel(this.props.cifText, "cif");
|
|
@@ -42,12 +52,30 @@ class Visualizer3dmol extends React.Component {
|
|
|
42
52
|
this.viewer.addUnitCell(this.model);
|
|
43
53
|
let sc = this.props.viewerParams.supercell;
|
|
44
54
|
this.viewer.replicateUnitCell(sc[0], sc[1], sc[2], this.model);
|
|
55
|
+
|
|
45
56
|
this.model.assignBonds();
|
|
46
57
|
|
|
47
|
-
|
|
48
|
-
|
|
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
|
+
}
|
|
49
76
|
|
|
50
77
|
this.viewer.zoomTo();
|
|
78
|
+
this.viewer.zoom(1.4);
|
|
51
79
|
this.viewer.render();
|
|
52
80
|
}
|
|
53
81
|
|
|
@@ -64,13 +92,11 @@ class Visualizer3dmol extends React.Component {
|
|
|
64
92
|
this.viewer.setView([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0]);
|
|
65
93
|
}
|
|
66
94
|
this.viewer.zoomTo();
|
|
95
|
+
this.viewer.zoom(1.4);
|
|
67
96
|
}
|
|
68
97
|
}
|
|
69
98
|
|
|
70
99
|
render() {
|
|
71
|
-
if (this.viewer && this.model) {
|
|
72
|
-
this.updateView();
|
|
73
|
-
}
|
|
74
100
|
return (
|
|
75
101
|
<div id={this.divId} className="gldiv">
|
|
76
102
|
No data!
|
|
@@ -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,49 @@
|
|
|
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>
|
|
24
|
+
<div
|
|
25
|
+
className="structure-window-outer"
|
|
26
|
+
onClick={() => this.props.setMouseEnabledState(true)}
|
|
27
|
+
>
|
|
28
|
+
<div className={swClassName}>
|
|
29
|
+
<Visualizer3dmol
|
|
30
|
+
ref={this.props.visualizerRef}
|
|
31
|
+
viewerParams={this.props.viewerParams}
|
|
32
|
+
cifText={this.props.cifText}
|
|
33
|
+
/>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
<div
|
|
37
|
+
className={mouseNoteClass}
|
|
38
|
+
onClick={() =>
|
|
39
|
+
this.props.setMouseEnabledState(!this.props.mouseEnabled)
|
|
40
|
+
}
|
|
41
|
+
>
|
|
42
|
+
{mouseNoteText}
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default StructureWindow;
|
|
@@ -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
|
}
|
|
@@ -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.setMouseEnabledState = this.setMouseEnabledState.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
|
+
setMouseEnabledState(state) {
|
|
51
|
+
this.setState({ mouseEnabled: state });
|
|
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
|
+
setMouseEnabledState={this.setMouseEnabledState}
|
|
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();
|