Skip to content
Snippets Groups Projects
Commit 6d7d3c07 authored by Alexander Rose's avatar Alexander Rose
Browse files

unitcell label tweaks

parent 92b988a8
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,7 @@ import { Model } from '../../model' ...@@ -11,6 +11,7 @@ import { Model } from '../../model'
import { Spacegroup } from '../../../../mol-math/geometry'; import { Spacegroup } from '../../../../mol-math/geometry';
import { Vec3 } from '../../../../mol-math/linear-algebra'; import { Vec3 } from '../../../../mol-math/linear-algebra';
import { ModelSymmetry } from '../../../../mol-model-formats/structure/property/symmetry'; import { ModelSymmetry } from '../../../../mol-model-formats/structure/property/symmetry';
import { radToDeg } from '../../../../mol-math/misc';
/** Determine an atom set and a list of operators that should be applied to that set */ /** Determine an atom set and a list of operators that should be applied to that set */
export interface OperatorGroup { export interface OperatorGroup {
...@@ -67,6 +68,25 @@ namespace Symmetry { ...@@ -67,6 +68,25 @@ namespace Symmetry {
const symmetry = ModelSymmetry.Provider.get(model) const symmetry = ModelSymmetry.Provider.get(model)
return symmetry ? arrayFind(symmetry.assemblies, a => a.id.toLowerCase() === _id) : undefined; return symmetry ? arrayFind(symmetry.assemblies, a => a.id.toLowerCase() === _id) : undefined;
} }
export function getUnitcellLabel(symmetry: Symmetry) {
const { cell, name, num } = symmetry.spacegroup
const { size, anglesInRadians } = cell
const a = size[0].toFixed(2)
const b = size[1].toFixed(2)
const c = size[2].toFixed(2)
const alpha = radToDeg(anglesInRadians[0]).toFixed(2)
const beta = radToDeg(anglesInRadians[1]).toFixed(2)
const gamma = radToDeg(anglesInRadians[2]).toFixed(2)
const label: string[] = []
// name
label.push(`Unitcell <b>${name}</b> #${num}`)
// sizes
label.push(`${a}\u00D7${b}\u00D7${c} \u212B`)
// angles
label.push(`\u03b1=${alpha}\u00B0 \u03b2=${beta}\u00B0 \u03b3=${gamma}\u00B0`)
return label.join(' | ')
}
} }
export { Symmetry } export { Symmetry }
\ No newline at end of file
...@@ -31,10 +31,8 @@ export class UnitcellEntry extends PurePluginUIComponent<{ cell: UnitcellCell }, ...@@ -31,10 +31,8 @@ export class UnitcellEntry extends PurePluginUIComponent<{ cell: UnitcellCell },
highlight = (e: React.MouseEvent<HTMLElement>) => { highlight = (e: React.MouseEvent<HTMLElement>) => {
e.preventDefault(); e.preventDefault();
if (!this.props.cell.state.isHidden) {
PluginCommands.Interactivity.Object.Highlight(this.plugin, { state: this.props.cell.parent, ref: this.props.cell.transform.ref }); PluginCommands.Interactivity.Object.Highlight(this.plugin, { state: this.props.cell.parent, ref: this.props.cell.transform.ref });
} }
}
clearHighlight = (e: React.MouseEvent<HTMLElement>) => { clearHighlight = (e: React.MouseEvent<HTMLElement>) => {
e.preventDefault(); e.preventDefault();
...@@ -56,10 +54,12 @@ export class UnitcellEntry extends PurePluginUIComponent<{ cell: UnitcellCell }, ...@@ -56,10 +54,12 @@ export class UnitcellEntry extends PurePluginUIComponent<{ cell: UnitcellCell },
const { obj } = cell; const { obj } = cell;
if (!obj) return null; if (!obj) return null;
const { label, description } = obj
return <> return <>
<div className='msp-btn-row-group' style={{ marginTop: '6px' }}> <div className='msp-btn-row-group' style={{ marginTop: '6px' }}>
<button className='msp-form-control msp-control-button-label' title={`Unitcell. Click to focus.`} onClick={this.focus} onMouseEnter={this.highlight} onMouseLeave={this.clearHighlight} style={{ textAlign: 'left' }}> <button className='msp-form-control msp-control-button-label' title={`${label}. Click to focus.`} onClick={this.focus} onMouseEnter={this.highlight} onMouseLeave={this.clearHighlight} style={{ textAlign: 'left' }}>
Unitcell {label} <small>{description}</small>
</button> </button>
<IconButton customClass='msp-form-control' onClick={this.toggleVisibility} icon='visual-visibility' toggleState={!cell.state.isHidden} title={`${cell.state.isHidden ? 'Show' : 'Hide'}`} small style={{ flex: '0 0 32px' }} /> <IconButton customClass='msp-form-control' onClick={this.toggleVisibility} icon='visual-visibility' toggleState={!cell.state.isHidden} title={`${cell.state.isHidden ? 'Show' : 'Hide'}`} small style={{ flex: '0 0 32px' }} />
<IconButton customClass='msp-form-control' onClick={this.toggleOptions} icon='dot-3' title='Options' toggleState={this.state.showOptions} style={{ flex: '0 0 32px', padding: '0px' }} /> <IconButton customClass='msp-form-control' onClick={this.toggleOptions} icon='dot-3' title='Options' toggleState={this.state.showOptions} style={{ flex: '0 0 32px', padding: '0px' }} />
......
...@@ -15,7 +15,6 @@ import { MeshBuilder } from '../../../mol-geo/geometry/mesh/mesh-builder'; ...@@ -15,7 +15,6 @@ import { MeshBuilder } from '../../../mol-geo/geometry/mesh/mesh-builder';
import { BoxCage } from '../../../mol-geo/primitive/box'; import { BoxCage } from '../../../mol-geo/primitive/box';
import { Mat4, Vec3 } from '../../../mol-math/linear-algebra'; import { Mat4, Vec3 } from '../../../mol-math/linear-algebra';
import { transformCage, cloneCage } from '../../../mol-geo/primitive/cage'; import { transformCage, cloneCage } from '../../../mol-geo/primitive/cage';
import { radToDeg } from '../../../mol-math/misc';
import { Sphere3D } from '../../../mol-math/geometry'; import { Sphere3D } from '../../../mol-math/geometry';
import { RepresentationParamsGetter, Representation, RepresentationContext } from '../../representation'; import { RepresentationParamsGetter, Representation, RepresentationContext } from '../../representation';
...@@ -80,29 +79,10 @@ function getUnitcellMesh(data: UnitcellData, props: UnitcellProps, mesh?: Mesh) ...@@ -80,29 +79,10 @@ function getUnitcellMesh(data: UnitcellData, props: UnitcellProps, mesh?: Mesh)
return m return m
} }
function getUnitcellLabel(data: UnitcellData) {
const { cell, name, num } = data.symmetry.spacegroup
const { size, anglesInRadians } = cell
const a = size[0].toFixed(2)
const b = size[1].toFixed(2)
const c = size[2].toFixed(2)
const alpha = radToDeg(anglesInRadians[0]).toFixed(2)
const beta = radToDeg(anglesInRadians[1]).toFixed(2)
const gamma = radToDeg(anglesInRadians[2]).toFixed(2)
const label: string[] = []
// name
label.push(`${name} #${num}`)
// sizes
label.push(`${a}\u00D7${b}\u00D7${c} \u212B`)
// angles
label.push(`\u03b1=${alpha}\u00B0 \u03b2=${beta}\u00B0 \u03b3=${gamma}\u00B0`)
return label.join(' | ')
}
function getUnitcellShape(ctx: RuntimeContext, data: UnitcellData, props: UnitcellProps, shape?: Shape<Mesh>) { function getUnitcellShape(ctx: RuntimeContext, data: UnitcellData, props: UnitcellProps, shape?: Shape<Mesh>) {
const geo = getUnitcellMesh(data, props, shape && shape.geometry); const geo = getUnitcellMesh(data, props, shape && shape.geometry);
const label = getUnitcellLabel(data) const label = Symmetry.getUnitcellLabel(data.symmetry)
return Shape.create('Unitcell', data, geo, () => props.cellColor, () => 1, () => label) return Shape.create(label, data, geo, () => props.cellColor, () => 1, () => label)
} }
// //
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment