Browse Source

selection and focus tweaks

- support highlight for current selection UI
Alexander Rose 5 years ago
parent
commit
79b33bfbd8
2 changed files with 16 additions and 4 deletions
  1. 3 1
      src/mol-plugin-ui/structure/focus.tsx
  2. 13 3
      src/mol-plugin-ui/structure/selection.tsx

+ 3 - 1
src/mol-plugin-ui/structure/focus.tsx

@@ -119,7 +119,9 @@ export class StructureFocusControls extends PluginUIComponent<{}, StructureFocus
                 ...ActionMenu.createItems(history, {
                     label: f => f.label,
                     description: f => {
-                        return f.label !== f.category ? `${f.category} | ${f.label}` : f.label
+                        return f.category && f.label !== f.category
+                            ? `${f.category} | ${f.label}`
+                            : f.label
                     }
                 })
             ])

+ 13 - 3
src/mol-plugin-ui/structure/selection.tsx

@@ -76,9 +76,8 @@ export class StructureSelectionControls<P, S extends StructureSelectionControlsS
 
     focus = () => {
         if (this.plugin.managers.structure.selection.stats.elementCount === 0) return;
-        const principalAxes = this.plugin.managers.structure.selection.getPrincipalAxes();
         const { sphere } = this.plugin.managers.structure.selection.getBoundary();
-        this.plugin.managers.camera.focusSphere(sphere, { principalAxes });
+        this.plugin.managers.camera.focusSphere(sphere);
     }
 
     setProps = (props: any) => {
@@ -132,6 +131,17 @@ export class StructureSelectionControls<P, S extends StructureSelectionControlsS
     toggleSet = this.showAction('set')
     toggleColor = this.showAction('color')
 
+    highlight = (e: React.MouseEvent<HTMLElement>) => {
+        this.plugin.managers.interactivity.lociHighlights.clearHighlights();
+        this.plugin.managers.structure.selection.entries.forEach(e => {
+            this.plugin.managers.interactivity.lociHighlights.highlight({ loci: e.selection }, false);
+        })
+    }
+
+    clearHighlight = () => {
+        this.plugin.managers.interactivity.lociHighlights.clearHighlights();
+    }
+
     get controls() {
         return <>
             <div className='msp-flex-row'>
@@ -170,7 +180,7 @@ export class StructureSelectionControls<P, S extends StructureSelectionControlsS
             <ParameterControls params={StructureSelectionParams} values={this.values} onChangeValues={this.setProps} />
             {this.controls}
             <div className='msp-flex-row' style={{ margin: '6px 0' }}>
-                <Button noOverflow onClick={this.focus} title='Click to Focus Selection' disabled={empty}
+                <Button noOverflow onClick={this.focus} title='Click to Focus Selection' disabled={empty} onMouseEnter={this.highlight} onMouseLeave={this.clearHighlight}
                     style={{ textAlignLast: !empty ? 'left' : void 0 }}>
                     {this.stats}
                 </Button>