@@ -25,8 +25,13 @@ import {
25
25
Button ,
26
26
Menu ,
27
27
MenuItem ,
28
+ Tooltip ,
28
29
Typography ,
29
- FormControlLabel
30
+ FormControl ,
31
+ FormLabel ,
32
+ FormControlLabel ,
33
+ Radio ,
34
+ RadioGroup
30
35
} from '@material-ui/core'
31
36
import { Alert } from '@material-ui/lab'
32
37
import {
@@ -47,6 +52,11 @@ import { withErrorHandler, withWebGLErrorHandler } from '../ErrorHandler'
47
52
import { isNil } from 'lodash'
48
53
import { Quantity } from '../../units'
49
54
55
+ export const WrapMode = {
56
+ Original : "original" ,
57
+ Wrap : "wrap" ,
58
+ Unwrap : "unwrap"
59
+ }
50
60
/**
51
61
* Used to control a 3D system visualization that is implemented in the
52
62
* 'children' prop. This allows for an easier change of visualization
@@ -84,6 +94,11 @@ const useStyles = makeStyles((theme) => {
84
94
title : {
85
95
marginBottom : theme . spacing ( 1 )
86
96
} ,
97
+ menuItem : {
98
+ margin : theme . spacing ( 2 ) ,
99
+ marginTop : theme . spacing ( 1 ) ,
100
+ marginBottom : theme . spacing ( 1 )
101
+ } ,
87
102
canvas : {
88
103
position : 'relative' ,
89
104
flex : 1 ,
@@ -94,9 +109,9 @@ const useStyles = makeStyles((theme) => {
94
109
}
95
110
} )
96
111
const StructureBase = React . memo ( ( {
97
- wrap ,
98
- onWrap ,
99
- disableWrap ,
112
+ wrapMode ,
113
+ onWrapModeChange ,
114
+ disableWrapMode ,
100
115
showLatticeConstants,
101
116
onShowLatticeConstants,
102
117
disableShowLatticeConstants,
@@ -137,9 +152,9 @@ const StructureBase = React.memo(({
137
152
onShowBonds && onShowBonds ( value , render )
138
153
} , [ onShowBonds ] )
139
154
140
- const handleWrap = useCallback ( ( value , showBonds , render = false ) => {
141
- onWrap && onWrap ( value , showBonds , render )
142
- } , [ onWrap ] )
155
+ const handleWrapModeChange = useCallback ( ( value , showBonds , render = false ) => {
156
+ onWrapModeChange && onWrapModeChange ( value , showBonds , render )
157
+ } , [ onWrapModeChange ] )
143
158
144
159
const handleShowLatticeConstants = useCallback ( ( value , render = false ) => {
145
160
onShowLatticeConstants && onShowLatticeConstants ( value , render )
@@ -261,58 +276,68 @@ const StructureBase = React.memo(({
261
276
open = { open }
262
277
onClose = { closeMenu }
263
278
>
264
- < MenuItem key = 'show-bonds' >
265
- < FormControlLabel
266
- control = {
267
- < Checkbox
268
- checked = { showBonds }
269
- disabled = { disableShowBonds }
270
- onChange = { ( event ) => { setShowBonds ( ! showBonds , true ) } }
271
- color = 'primary'
272
- />
273
- }
274
- label = 'Show bonds'
275
- />
276
- </ MenuItem >
277
- < MenuItem key = 'show-axis' >
278
- < FormControlLabel
279
- control = {
280
- < Checkbox
281
- checked = { showLatticeConstants }
282
- disabled = { disableShowLatticeConstants }
283
- onChange = { ( event ) => { handleShowLatticeConstants ( ! showLatticeConstants , true ) } }
284
- color = 'primary'
285
- />
286
- }
287
- label = 'Show lattice constants'
288
- />
289
- </ MenuItem >
290
- < MenuItem key = 'show-cell' >
291
- < FormControlLabel
292
- control = {
293
- < Checkbox
294
- checked = { showCell }
295
- disabled = { disableShowCell }
296
- onChange = { ( event ) => { setShowCell ( ! showCell , true ) } }
297
- color = 'primary'
298
- />
299
- }
300
- label = 'Show simulation cell'
301
- />
302
- </ MenuItem >
303
- < MenuItem key = 'wrap' >
304
- < FormControlLabel
305
- control = {
306
- < Checkbox
307
- checked = { wrap }
308
- disabled = { disableWrap }
309
- onChange = { ( event ) => { handleWrap ( ! wrap , showBonds , true ) } }
310
- color = 'primary'
311
- />
312
- }
313
- label = 'Wrap positions'
314
- />
315
- </ MenuItem >
279
+ < MenuItem key = 'show-bonds' >
280
+ < FormControlLabel
281
+ control = {
282
+ < Checkbox
283
+ checked = { showBonds }
284
+ disabled = { disableShowBonds }
285
+ onChange = { ( event ) => { setShowBonds ( ! showBonds , true ) } }
286
+ color = 'primary'
287
+ />
288
+ }
289
+ label = 'Show bonds'
290
+ />
291
+ </ MenuItem >
292
+ < MenuItem key = 'show-axis' >
293
+ < FormControlLabel
294
+ control = {
295
+ < Checkbox
296
+ checked = { showLatticeConstants }
297
+ disabled = { disableShowLatticeConstants }
298
+ onChange = { ( event ) => { handleShowLatticeConstants ( ! showLatticeConstants , true ) } }
299
+ color = 'primary'
300
+ />
301
+ }
302
+ label = 'Show lattice constants'
303
+ />
304
+ </ MenuItem >
305
+ < MenuItem key = 'show-cell' >
306
+ < FormControlLabel
307
+ control = {
308
+ < Checkbox
309
+ checked = { showCell }
310
+ disabled = { disableShowCell }
311
+ onChange = { ( event ) => { setShowCell ( ! showCell , true ) } }
312
+ color = 'primary'
313
+ />
314
+ }
315
+ label = 'Show simulation cell'
316
+ />
317
+ </ MenuItem >
318
+ < FormControl key = 'wrap' component = "fieldset" className = { styles . menuItem } >
319
+ < FormLabel component = "legend" > Wrap mode</ FormLabel >
320
+ < RadioGroup
321
+ value = { wrapMode }
322
+ onChange = { handleWrapModeChange }
323
+ >
324
+ { Object . entries ( WrapMode ) . map ( ( [ key , value ] ) =>
325
+ < FormControlLabel
326
+ key = { key }
327
+ value = { value }
328
+ control = { < Radio color = "primary" disabled = { disableWrapMode } /> }
329
+ label = { < Tooltip
330
+ title = { {
331
+ [ WrapMode . Original ] : 'Original positions' ,
332
+ [ WrapMode . Wrap ] : 'Positions wrapped inside the cell respecting periodic boundary conditions' ,
333
+ [ WrapMode . Unwrap ] : 'Reconstructs positions so that small structures are not split by periodic cell boundary.'
334
+ } [ value ] } >
335
+ < span > { key } </ span >
336
+ </ Tooltip > }
337
+ />
338
+ ) }
339
+ </ RadioGroup >
340
+ </ FormControl >
316
341
</ Menu >
317
342
</ div >
318
343
</ div >
@@ -321,9 +346,9 @@ const StructureBase = React.memo(({
321
346
} )
322
347
323
348
StructureBase . propTypes = {
324
- wrap : PropTypes . bool ,
325
- onWrap : PropTypes . func ,
326
- disableWrap : PropTypes . bool ,
349
+ wrapMode : PropTypes . bool ,
350
+ onWrapModeChange : PropTypes . func ,
351
+ disableWrapMode : PropTypes . bool ,
327
352
showLatticeConstants : PropTypes . bool ,
328
353
onShowLatticeConstants : PropTypes . func ,
329
354
disableShowLatticeConstants : PropTypes . bool ,
0 commit comments