@@ -15,8 +15,8 @@ const DefaultSymmetryParams = {
15
15
on : PD . Boolean ( false , { isHidden : true } ) ,
16
16
/** Index of the currently selected symmetry (in case there a more symmetries for an assembly), regardless of whether visibility is on of off */
17
17
symmetryIndex : PD . Select ( 0 , [ [ 0 , 'Auto' ] ] ) ,
18
- /** `true` if symmetry data have been retrieved but do not contain any non-trivial symmetry */
19
- noSymmetries : PD . Boolean ( false , { isHidden : true } ) ,
18
+ /** `true` if visibility is on and symmetry data have been retrieved and contain at least one non-trivial symmetry. */
19
+ hasSymmetries : PD . Boolean ( false , { isHidden : true } ) ,
20
20
} ;
21
21
22
22
type SymmetryParams = typeof DefaultSymmetryParams ;
@@ -64,24 +64,24 @@ export class SymmetryAnnotationControls extends PurePluginUIComponent<{}, Symmet
64
64
/** Synchronize parameters and values in UI with real parameters currently applied in `AssemblySymmetryProvider` */
65
65
syncParams ( ) {
66
66
if ( this . hasAssemblySymmetry3D ( ) ) {
67
- const noSymmetries = this . noSymmetriesAvailable ( ) ;
67
+ const hasSymmetries = this . hasSymmetriesAvailable ( ) ;
68
68
const realParams = this . getRealParams ( ) ;
69
69
const realValues = this . getRealValues ( ) ;
70
- const options = noSymmetries ?
71
- [ [ 0 , 'None' ] ] as const
72
- : realParams . symmetryIndex . options . filter ( ( [ index , label ] ) => index >= 0 ) ; // Removing the 'off' option (having index -1)
70
+ const options = hasSymmetries ?
71
+ realParams . symmetryIndex . options . filter ( ( [ index , label ] ) => index >= 0 ) // Removing the 'off' option (having index -1)
72
+ : [ [ 0 , 'None' ] ] as const ;
73
73
const params = {
74
74
...this . state . params ,
75
75
symmetryIndex : PD . Select ( 0 , options ) ,
76
76
} ;
77
- const values = ( realValues . symmetryIndex >= 0 ) ? {
77
+ const values : SymmetryProps = ( realValues . symmetryIndex >= 0 ) ? {
78
78
on : true ,
79
79
symmetryIndex : realValues . symmetryIndex ,
80
- noSymmetries : noSymmetries ,
80
+ hasSymmetries ,
81
81
} : {
82
82
on : false ,
83
83
symmetryIndex : this . state . values . symmetryIndex ,
84
- noSymmetries : noSymmetries ,
84
+ hasSymmetries ,
85
85
} ;
86
86
this . setState ( { params, values } ) ;
87
87
} else {
@@ -92,11 +92,11 @@ export class SymmetryAnnotationControls extends PurePluginUIComponent<{}, Symmet
92
92
}
93
93
}
94
94
95
- /** Return `true` if symmetry data have been retrieved and do not contain any non-trivial symmetry. */
96
- noSymmetriesAvailable ( ) {
95
+ /** Return `true` if symmetry data have been retrieved and contain at least one non-trivial symmetry. */
96
+ hasSymmetriesAvailable ( ) {
97
97
const structure = this . getPivotStructure ( ) ?. cell . obj ?. data ;
98
98
const symmetryData = structure && AssemblySymmetryDataProvider . get ( structure ) . value ;
99
- return symmetryData !== undefined && symmetryData . filter ( sym => sym . symbol !== 'C1' ) . length === 0 ;
99
+ return symmetryData !== undefined && symmetryData . filter ( sym => sym . symbol !== 'C1' ) . length > 0 ;
100
100
}
101
101
102
102
/** Get the first loaded structure, if any. */
@@ -205,28 +205,20 @@ export class SymmetryAnnotationControls extends PurePluginUIComponent<{}, Symmet
205
205
}
206
206
207
207
render ( ) {
208
- const shortTitle = 'Assembly Symmetry' + ( this . state . values . noSymmetries ? ' [Not Available]' : '' ) ;
209
- const title = 'Assembly Symmetry' + ( this . state . values . noSymmetries ? ' [Not Available]\nSymmetry information for this assembly is not available' : '' ) ;
208
+ const notAvailable = this . state . values . on && ! this . state . values . hasSymmetries ;
209
+ const shortTitle = 'Assembly Symmetry' + ( notAvailable ? ' [Not Available]' : '' ) ;
210
+ const title = 'Assembly Symmetry' + ( notAvailable ? ' [Not Available]\nSymmetry information for this assembly is not available' : '' ) ;
210
211
return < >
211
- < SymmetryAnnotationRowControls shortTitle = { shortTitle } title = { title }
212
+ < AnnotationRowControls shortTitle = { shortTitle } title = { title }
212
213
applied = { this . state . values . on } onChangeApplied = { applied => this . apply ( applied ) }
213
- params = { this . state . params } values = { this . state . values } onChangeValues = { v => this . changeParamValues ( v ) } />
214
+ params = { this . state . params } values = { this . state . values } onChangeValues = { v => this . changeParamValues ( v ) }
215
+ errorMessage = { ! this . state . values . on ? 'First activate annotation to show options' : notAvailable ? 'Symmetry information not available' : undefined }
216
+ />
214
217
</ > ;
215
218
}
216
219
}
217
220
218
221
219
- class SymmetryAnnotationRowControls extends AnnotationRowControls < SymmetryParams > {
220
- renderOptions ( ) {
221
- if ( this . props . values . noSymmetries ) {
222
- return < div className = 'msp-row-text' >
223
- < div title = 'Symmetry information for this assembly is not available' > Symmetry information not available</ div >
224
- </ div > ;
225
- }
226
- return super . renderOptions ( ) ;
227
- }
228
- }
229
-
230
222
/** Get the first loaded structure, if any. */
231
223
function getPivotStructure ( plugin : PluginContext ) : StructureRef | undefined {
232
224
return plugin . managers . structure . hierarchy . selection . structures [ 0 ] ;
0 commit comments