forked from molstar/pdbe-molstar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
component-demo.html
146 lines (123 loc) · 7.25 KB
/
component-demo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<title>Mol* PDBe Wrapper</title>
<!-- Required for IE11 -->
<script src="https://cdn.jsdelivr.net/npm/babel-polyfill/dist/polyfill.min.js"></script>
<!-- Web component polyfill (only loads what it needs) -->
<script src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs/webcomponents-lite.js" charset="utf-8"></script>
<!-- Required to polyfill modern browsers as code is ES5 for IE... -->
<script src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="build/pdbe-molstar-3.0.0.css">
<script type="text/javascript" src="build/pdbe-molstar-component-3.0.0.js"></script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.msp-plugin ::-webkit-scrollbar-thumb {
background-color: #474748 !important;
}
.viewerSection {
padding-top: 40px;
}
.controlsSection {
width: 300px;
float: left;
padding: 40px 0 0 40px;
margin-right: 30px;
}
.controlBox {
border: 1px solid lightgray;
padding: 10px;
margin-bottom: 20px;
}
#myViewer{
float:left;
width:450px;
height: 450px;
position:relative;
}
</style>
</head>
<body>
<div class="controlsSection">
<h3>Canvas/ layout methods</h3>
<div class="controlBox">
<strong>Set Background</strong><br>
<button onclick="viewerInstance.canvas.setBgColor({r:255, g:255, b:255})">White</button>
<button onclick="viewerInstance.canvas.setBgColor({r:0, g:0, b:0})">Black</button><br><br>
<strong>Toggle controls menu</strong><br>
<button onclick="viewerInstance.canvas.toggleControls(false)">Hide</button>
<button onclick="viewerInstance.canvas.toggleControls(true)">Show</button>
<button onclick="viewerInstance.canvas.toggleControls()">Toggle</button><br><br>
<strong>Toggle Fullscreen</strong><br>
<button onclick="viewerInstance.canvas.toggleExpanded(true)">Show Fullscreen</button><br>
</div>
<h3>Visual Methods</h3>
<div class="controlBox">
<strong>Change representation visibility</strong><br>
<button onclick="viewerInstance.visual.visibility({water:false})">Hide Water Visual</button>
<button onclick="viewerInstance.visual.visibility({water:true})">Show Water Visual</button><br><br>
<strong>Toggle Spin</strong><br>
<button onclick="viewerInstance.visual.toggleSpin(true)">Rotate</button>
<button onclick="viewerInstance.visual.toggleSpin(false)">Stop</button>
<button onclick="viewerInstance.visual.toggleSpin()">Toggle</button><br><br>
<strong>Focus</strong><br>
<button onclick="viewerInstance.visual.focus([{struct_asym_id: 'A', start_residue_number: 14, end_residue_number: 18}])">Focus on Chain A:14-18</button><br><br>
<strong>Highlight</strong><br>
<button onclick="viewerInstance.visual.highlight({ data: [{ struct_asym_id: 'A', start_residue_number: 14, end_residue_number: 18 }], color:{r:255,g:255,b:0} })">Highlight Chain A:14-18</button>
<button onclick="viewerInstance.visual.clearHighlight()">Clear Highlight</button><br><br>
<strong>Selection</strong><br>
<button onclick="viewerInstance.visual.select({ data: [{ struct_asym_id: 'B', start_residue_number: 1, end_residue_number: 6, color:{r:255,g:255,b:0}, focus: true }]})">Select & Focus on Chain B:1-6</button><br><br>
<button onclick="
var selectSections = [
{
struct_asym_id: 'B',
start_residue_number: 8,
end_residue_number: 10,
color:{r:255,g:0,b:255},
sideChain: true
},
{
struct_asym_id: 'B',
start_residue_number: 2,
end_residue_number: 5,
color:{r:255,g:0,b:0}
}
]
viewerInstance.visual.select({ data: selectSections, nonSelectedColor: {r:255,g:255,b:255}})">Select on Chain B:2-5 & Chain B:8-10</button><br><br>
<button onclick="viewerInstance.visual.select({ data: [{struct_asym_id: 'B', color:{r:255,g:255,b:0}, focus:true}], nonSelectedColor: {r:255,g:255,b:255} })">Select & Focus on Chain B</button><br><br>
<button onclick="viewerInstance.visual.clearSelection()">Clear Selection</button><br><br>
<strong>Set highlight / selection colour</strong><br>
<button onclick="viewerInstance.visual.setColor({ highlight: {r:255,g:255,b:0} })">Yellow highlight</button>
<button onclick="viewerInstance.visual.reset({ highlightColor: true })">Reset</button><br><br>
<button onclick="viewerInstance.visual.setColor({ select: {r:255,g:0,b:0} })">Red selection</button>
<button onclick="viewerInstance.visual.reset({ selectColor: true })">Reset</button><br><br>
<strong>Reset Visual</strong><br>
<button onclick="viewerInstance.visual.reset({ camera: true })">Camera</button>
<button onclick="viewerInstance.visual.reset({ theme: true })">Theme</button>
<button onclick="viewerInstance.visual.reset({ camera: true, theme: true })">Camera & Theme</button><br><br>
<strong>Update data</strong><br>
<button onclick="viewerInstance.visual.update({moleculeId: '1cbs'})">Update data to create new visual</button><br>
</div>
</div>
<div class="viewerSection">
<h4>PDBe Mol* Web-component Demo</h4>
<!-- Molstar container -->
<div style="float:left;position: relative;width:400px;height: 400px;">
<pdbe-molstar id="pdbeMolstarComponent" molecule-id="2nnu" hide-controls="true" pdbe-link="false"></pdbe-molstar>
</div>
</div>
<script>
var viewerInstance;
window.onload = function () {
var pdbeMolstarComponent = document.getElementById('pdbeMolstarComponent');
viewerInstance = pdbeMolstarComponent.viewerInstance;
};
</script>
</body>
</html>